Launching my First EC2 Instance and More…

Aerielellisk
5 min readSep 12, 2022

--

This week at Level Up in Tech, we are finally getting our hands a little bit dirty with AWS. The goal of this lab is to launch an EC2 Instance on Amazon, create a security group that allows inbound traffic from my IP Address, and then install an Apache with a custom webpage using a BASH script.

Definitely sounds like a good chunk of work, so it’s time to get started!

First, I going to go ahead and sign into AWS as a IAM user (not the Root user), and start by creating a VPC (Virtual Private Cloud) that will eventually hold/isolate my EC2 instance.

I start by giving my VPC a custom name to remember it by and then givng my range of IP Address in the IPv4-CIDR block field — going with the default gives me thousands of IP Addresses that will be able to connect to my VPC. For this project I won’t need additional addresses, so the IPv6 CIDR block field can stick to No, and the tenacy can say default because I will be using a shared hardware (hence the reason why I’m using a VPC). Last step is to press “Create VPC”

Next step is to get my subnet up and running. Subnets are isolated local networks that live inside of the VPC, and this is where the EC2 will be launched.

Once the VPC is created, on the left panel of my AWS console, I can select the “Subnet” option to set up the Subnet that will be housing my EC2 instance.

I’ll create my Subnet by click the “Create Subnet” button. Now I need to connect my Subnet to the VPC I just created, by selected it in the dropdown menu of VPC IDs. Once Ive selected my subnet, I can add the name, availability zone, and CIDR Block range that I want to use for my subnet. No tags are necessary at this point, so I can go ahead and create my subnet

At this point, my subnet is connected to my VPC, but it is not public, and I need it to be public so it can welcome traffic from my IP Address as well. So next steps is to set up the internet gateway!

Down in my subnet settings, I will need to modify the Subnet settings to make sure that it will automatically request IP Addresses for the EC2 instance we will be launching shortly.

Once that is all settled, on the left panel again I can select “Internet Gateways”, then “Create Internet Gateway”, give it a name and the create the gateway. Once that is set, I can now attach the Internet Gateway to the VPC that I originally created. Once that is done, it is on to create a Route table for the subnet

On the left panel again, I can go to “Route Tables”, and select “Create a Route Table”. There I will be able to name my route table and attach that to my VPC.

Once that is create, I can select “Edit Route”, and I can set the Destination to 0.0.0.0/0 — that’s the public internet. And the target I can set as my Internet gateway that I recently created.

Now I need to do the opposite, and make sure that the Subnet can connect with the public internet. To do that, I’ll choose the “Subnet Associations” tab, select the subnet that I created, and then click “Save association”

Finally, I am able to launch an EC2 Instance into my subnet (that is within my VPC).

At the top of the screen in the search bar, I need to search for EC2, click the first option and then click “Launch Instance”. Here I can set up what AMI I’d like to use, and in this case it will be the default Amazon Linux 2. The instance type will be a t2.micro (also the default state), and this is the point where I will download my keypair to ssh into my server later on in the project.

Next, I configured the security groups to accept incoming traffic from everywhere and also my own IP address, and then it was time to create my instance!

Next step is connected to the EC2 instance by ssh, and AWS has a handy step by step pop up that explains exactly what to do. The tricky part here is just to make sure that when you are running the commands, that the private key is in the same folder that you are in, or this wont work at all!

So now I’ve successfully ssh into my EC2 instance, now I just need to install Apache and create a webpage that will show from my public IP Address. Will have to update this part later, but that was a ton of work and here is my successful webpage from my public IP Address!

On to the next project at LUIT!

--

--