Launching an AWS EC2 Instance & Creating a Custom Webpage

A Beginner’s Guide to Launching Your First EC2

Melissa (Mel) Foster
Women in Technology
5 min readMar 12, 2023

--

Source: logos of companies.

You may be asking yourself what is AWS?

AWS is the abbreviation for Amazon Web Service.

Maybe you are a little curious why is everyone jumping on board with the cloud. As we all generally know Amazon is a multi-billion, multi-national company with a strong focus on technology with a global reach. Even though I knew this, I am still in awe over the fact AWS is not only the world’s largest but also the most comprehensive cloud platform. It offers something for everyone, from big companies like Netflix, to even services we personally can benefit from. With over 200+ services, we could talk for hours. However, today I want to walk through a project where we create an EC2 Instance together then run a custom Bash Script to install a custom Apache webpage.

  • EC2 Instance is a virtual server in Amazon’s Elastic Compute Cloud (EC2) used for running applications on the Amazon Web Services (AWS) infrastructure.

To follow along you will need an AWS Account as well as access to Terminal or PowerShell.

Adobe Stock Free Image

Now, let’s get started by logging into your AWS Account, and searching for EC2 and get set up for our launch.

Select EC2
Launch Instance

We are going to rename our Instance, and selecting our AMI (Amazon Machine Image) Template, Amazon Linux with an Instance Type t.2.mircro. (Free tier eligible)

Please note that a name is set and can only be used once.

Next we need to create a Key pair- which will allow us to securely connect to our instance.

You can customize your Key Pair to be uniquely yours.

Continuing, down the screen to our next area of focus Network settings. We want to create a security group that allows us to securely ssh into, while allowing public access to the webpage. We want to select SSH traffic from your personal IP, then click the next two boxes allowing HTTPS & HTTP traffic from the internet. Lastly, we can Launch our Instance.

Success!

Locate your Instance by either scrolling down the success page at the bottom select view Instances, or by clicking on the pathway Instance. Click on your Instance.

You can select by clicking on the highlighted text.
You can also click the connect to bring up information to ssh into from your Terminal or PowerShell

Heading over to our PowerShell or Terminal, we are going to get set up to ssh into our AWS EC2. It is important to note where your Key-pair is located on your working OS. My Key-pair initially downloaded into my download folder. I moved it to a directory for it to be easily found as a more direct path. While working on trying to follow the steps to connect to AWS EC2, I ran into errors of not being able to change into the directory I wanted in PowerShell. (I apologize that I forgot to screen grab the error) Regardless, it taught me more about PowerShell needing to have a Set Location. Using the command: Set- Location C:\ we can now use the command cd and paste in our direct path of our Key-pair.

Set-Location C:\

cd [Copy & Paste Location of your direct Path]

Our path is now set; lets ssh

ssh -i "key-pair.pem" ec2-user@ec2-[Address.com]
Your Screen should look a little something like this.

Let’s keep things simple and create our script. I will be using vim to create a script called apacheinstall.sh.

vim apacheinstall.sh

Time to make our script executable:

chmod +x apacheinstall.sh

Time to execute:

./apacheinstall.sh

And let’s check our Public IP

Yes! WE got Apache Installed!

If you would like to customize your webpage you can renter your script using vim, and then re-execute the file using the same command listed above.

Example Customization Script Added
Note: that my automatic Public IP Address changed once I stopped and restarted my AWS EC2 Instance.

Looks great right? I know there is more to learn about all the options when it comes to scripting. It’s fun to research and try out. Hope you enjoyed this project. I look forward to showing you an additional option which will utilize Git & GitHub.

Join me on https://www.linkedin.com/in/melissafoster08/ or follow me at https://github.com/mel-foster

--

--

Melissa (Mel) Foster
Women in Technology

𝔻𝕖𝕧𝕆𝕡𝕤 𝗘𝗻𝗴𝗶𝗻𝗲𝗲𝗿 |𝒲𝑜𝓂𝑒𝓃 𝐼𝓃 𝒯𝑒𝒸𝒽 𝒜𝒹𝓋𝑜𝒸𝒶𝓉𝑒 | 𝚂𝚘𝚌𝚒𝚊𝚕 𝙼𝚎𝚍𝚒𝚊 𝙲𝚛𝚎𝚊𝚝𝚘𝚛 | Photographer