How to Set up a Basic AWS Network Infrastructure
Use Case
Now after testing and moving a server over to EC2, the Level Up Bank is looking to move its network to the cloud to improve scalability, reliability, and security. The bank decides to use AWS for its cloud services and starts by creating a VPC with a CIDR of 10.10.0.0/16. Next, the bank creates three public subnets with CIDR blocks of 10.10.1.0/24, 10.10.2.0/24, and 10.10.3.0/24. These subnets will be used to host an autoscaling group of t2.micro instances with Apache installed on each instance.
The bank creates an autoscaling group with a minimum of 2 instances and a maximum of 5 instances. Each instance has Apache installed and is configured to produce a test page when checking a random IP address. The autoscaling group uses the three public subnets created earlier to ensure that instances are launched in different availability zones for high availability. To distribute traffic to the autoscaling group, the bank creates an Application Load Balancer. The Load Balancer is configured to use the web server security group created next.
The bank creates a web server security group that allows inbound traffic from HTTP from the Application Load Balancer. This security group ensures that the instances in the autoscaling group can receive traffic from the Load Balancer.
Finally, the bank creates a load balancer security group that allows inbound traffic from HTTP from 0.0.0.0/0. This security group ensures that the Load Balancer is accessible from the internet.
With this setup, The Level Up Bank can take advantage of the scalability, reliability, and security of AWS while maintaining the ability to host its own web applications. The bank can also save costs by using pay-as-you-go pricing for its instances and load balancers.
Prerequisites
1. Create a free tier account: https://aws.amazon.com/.
2. It may be helpful to review an article I previously posted that goes into more detail on EC2 Instances with a user data script:
Let’s start with the basics
- What is an AWS Virtual Private Cloud (VPC)? A Virtual Private Cloud (VPC) is a means to launching AWS resources in a virtual network. This virtual network is similar to a traditional network that is connected to a data center. However with VPC, you reap the benefits of the scalable infrastructure (virtually) without having physical limitations.
- What is a subnet? A subnet is a layer within the VPC. The subnets are made up of a range of IP addresses. This is a means of breaking up your network into different availability zones for redundancy and high availability. It also allows you to create private and public access.
- What is auto scaling? AWS’ auto scaling is a means to automatically adjust resources to meet demand, whether capacity needs to move up or down. This helps minimize costs by adjusting to only use resources as needed.
- What is a load balancer? AWS’ load balancer allows you to direct traffic across multiple targets. Imagine when you’re at the grocery store and the line to check out gets long; someone usually opens up another register to help lower the wait time. This kind of works similarly by directing traffic to different resources to help improve availability and response times.
- What is an internet gateway? An internet gateway allows the communication between the VPC and the internet. Imagine this as a bridge between the two systems.
- What is a route table? A route table is essentially a set of rules that control network traffic. With the use of IP addresses, it helps direct the network traffic.
Let’s begin walking through the use case deliverables.
How to Create a VPC:
- First, we will need to log into our AWS account. Our first step in this use case will be creating the Virtual Private Cloud (VPC). So, let’s navigate to the search bar and type in “VPC. ”
2. After clicking on VPC in step one, you will find yourself on the VPC dashboard. Locate the orange “Create VPC” and click on it.
3. You will then be directed to the VPC settings page. Make the below changes to your VPC settings. Once complete, click “Create VPC.”
- We want to ensure that the “VPC Only” option is selected.
- We want to input a VPC name. For this use case, I will name the VPC “Level_Up_Bank.”
- We will manually input the requested IPv4 CIDR: 10.10.0.0/16. The use case provided this specific CIDR.
4. You can find your newly created VPC under “Your VPCs.”
5. There is one revision we need to make to the VPC. Locate the Actions button and click “Edit VPC Settings” in the dropdown. We want to enable DNS hostnames. Click save.
6. And that’s all we need to do in order to create a new VPC. We will continue to build onto this VPC in the coming steps.
How to Create a Subnet:
- Now that the VPC is created, we can create our subnets. The use case tells us that we need to create 3 public subnets. Let’s start with navigating to the subnet section in AWS VPC.
2. Once you’re on the Subnets page, you should be able to locate the orange “Create subnet” button. Click it.
3. On the “Create Subnet” page, you will be asked to associate the subnet with a VPC. We need to select the VPC we just created.
4. After selecting the correct VPC, we need to modify additional subnet settings. We need to start by naming our subnet. For this example, I’ll keep it simple, and name is Public1. We need to select the desired availability zone. Since our VPC is in us-east-1 region, we will select the us-east-1a availability zone. The use case provided the CIDR block that we need to use: 10.10.1.0/24
5. We need to create two more subnets per the use case instructions. We can complete this by selecting the “Add new subnet” along the bottom. Let’s mirror the steps from Step 4.
We will need to name the subnets with different names. I’m going to use Public2 and Public3 for the other two subnets. We will ensure each subnet is in a different availability zone for redundancy. The other item changing will be the CIDR (10.10.2.0/24 and 10.10.3.0/24).
Once all three subnet settings are updated, we will click the orange “Create subnet” along the bottom.
6. It may take a moment for the subnets to build. Once the system completes processing, you’ll be able to find the three subnets.
7. For each subnet, we need to go to Actions and select “Edit subnet settings.” We will need to check the box to enable auto-assign public IPv4 address. Click save.
8. Now that we’ve created the VPC and subnets, we can create an internet gateway. The internet gateway will essentially connect the VPC to the internet.
9. After clicking on “Internet gateways” shown above, you should find an orange “Create internet gateway” button. Click on it. We will input the desired name and hit create.
10. Once the internet gateway is created, we need to attach it to the VPC. This is completed by locating the “Actions” button and selecting “Attach to VPC” in the dropdown. Select the VPC we recently created and click the orange “attach internet gateway” button.
11. We need to review the route table. When creating a VPC and subnets, a “main” route table is automatically created. We will need to add the newly created internet gateway to this route table. This is completed by selecting the route table tied to the VPC. The system usually doesn’t name this for us, so if you have multiple on your account, you may need to poke around to ensure you selected the correct route table tied to the VPC we want. You can add a label to rename the route table.
12. After locating the correct route table, locate Routes > Edit Routes.
13. After clicking “Edit Routes,” select “Add route.” Input 0.0.0.0/0 and add the new internet gateway. Click “Save changes” once complete.
How to Create an Auto Scaling Group:
Now that we’ve completed the basic networking set up, we can create an auto scaling group. This will help automate resources to meet capacity.
Listed below you will find the use case requirements for building out the auto scaling group:
- t2.micro instances
- Apache needs to be installed on each instance with a custom web page
- Need to use all three public subnets
- The autoscaling min and max should be 2 and 5.
- To create an auto scaling group, we need to navigate to EC2. The list along the lefthand side of your screen will have Auto Scaling Groups listed toward the bottom. Click on the “Auto Scaling Groups” option.
2. On the Auto Scaling Groups dashboard, locate the orange “Create Auto Scaling group” button. Click on it.
3. You will be redirected to the “Choose launch template” page. The first step is inputting a unique name for the auto scaling group. For this use case, I will name it “LevelUpBank_ASG.” Next, we need to create a launch template.
4. We will be redirected to the “Create launch template” page. I will name this “LevelUpBank_LT” and copy it into the name and description boxes.
5. I will select an AMI. I didn’t see anything in the use case specifying which AMI to use, so I’ll use the Amazon Linux AMI.
6. The use case specifies that we want t2.micro for the instance type.
7. Next, I will create a new key pair. I will name it LevelUpBank_KP. I will leave the remaining settings as the default selections.
8. For Network settings, I will leave the default subnet setting as “Don’t include in launch template.” I will create a new security group and name it “LevelUpBank_SG” and also use that in the description. At this time, I’m not going to create any inbound security group rules. Lastly, I will check that the correct VPC is selected.
9. I want to add user data that will install the Apache requirements described in the use case. The user data field is located within the “Advanced details” section. Scroll down toward the bottom to “user data”. We will input the following script within the user data section:
#!/bin/bash
yum update -y
yum install -y httpd
systemctl start httpd
systemctl enable httpdRefer to the article under the “Prerequisites” section at the beginning of this article to better understand how I came up with these commands in the script.
Get Madison Hersom’s stories in your inbox
Join Medium for free to get updates from this writer.
10. We’ve input all that we want to at this point, so let’s click on “Create launch template.” Once that has completed building, we want to navigate back to our Create Auto Scaling set up.
11. Back in our auto scaling group set up, click refresh until our newly created launch template displays.
12. Select the launch template we just created and click “Next.”
13. Review the “Choose instance launch options”. The correct launch template is listed. The correct instance type is listed.
14. Next, we will be prompted to select VPC and subnets. We will use the dropdown to select the correct VPC. We will also use the dropdown for “Availability Zones and Subnets” to select all three of the subnets. Click next.
15. For now, I’m going to skip setting up the load balancer. We’ll come back to this later. I’m going to leave the default settings for the rest of the items and click “next.”
16. For the “Configure group size and scaling policies” settings, I want to set the minimum capacity to 2 and the maximum capacity to 5. I pulled this information from the use case. I’m going to leave the other settings to the default selections and click next.
17. I’m going to skip adding notifications and click next.
18. I’m going to skip adding tags and click next.
19. Lastly, let’s scroll through and validate the settings we selected on the Review page. Once your review is complete, click the create auto scaling group button.
20. It may take a minute to process, but once complete, the auto scaling group will display.
How to Create an Application Load Balancer:
- The next item we want to set up is the load balancer. The load balancer will distribute traffic to the auto scaling group. Before creating a load balancer, we will want to create a target group. This is under EC2.
2. We will select “instances” and input the desired name.
3. We will keep HTTP and IPv4 selected. We will ensure our VPC is selected. Click “Create target group.”
4. Next, we want to create the load balancer. The Load Balancer section is under EC2. Review the list along the lefthand side and click on the “Load Balancers” option.
5. After clicking on “Load Balancers,” you will be directed to the dashboard. Click on the orange “Create load balancer” button.
6. We want to create an Application Load Balancer, so let’s select that option.
7. Under “Basic configuration,” we will input a name for the application load balancer. I will name it “LevelUpBank_ALB.” We will select the “Internet-facing” scheme since our subnets are all public. We will leave IPv4 selected.
8. We will want to ensure that the correct VPC is selected. Adjust accordingly with the dropdown list. Under the Mappings section, we will select all three of our subnets.
9. The next setting involves security groups. Select the security group previously made.
10. The “Listeners and routing” section will connect our application load balancer to the target group we created.
11. We made all desired setting changes and can now create the load balancer.
12. We need to associate the load balancer to the auto scaling group. Navigate back to the auto scaling group we created. Under Details, we are looking for the Load Balancing section. Click edit.
13. With this setting, we will “connect” the load balancer to the auto scaling group.
Security Group Revisions:
- The use case explains that we need to create a web server security group that allows inbound traffic from HTTP from the Application Load Balancer. As a security precaution, no one should be able to use the public IP of your web server to reach your website. All users should be using the Application Load Balancer.
2. After creating this security group, I went back to my launch template and added this security group.
3. We also need to ensure the Auto Scaling Group gets updated to the latest Launch Template version.
4. The use case also explains that we need to create a load balancer security group that allows inbound traffic from HTTP from 0.0.0.0/0. Update the load balancer settings appropriately with the new security group.
5. The intent of the two new security group is to make your network more secure. Let’s test it out by using the public IP address of our instances and DNS URL of the Application Load Balancer in a browser to verify we can reach the site.
By using the public IP address for an instance, we should NOT be able to access.
6. Now that we confirmed we cannot access our instances directly, we need to test that we CAN access our Application Load Balancer. This can be tested by copying the DNS URL and pasting into our browser.
7. Testing was the last deliverable of the use case. We’ve successfully built a basic cloud network infrastructure.
Troubleshooting
When setting up my load balancer, I was not able to select the VPC I wanted. This indicated that I missed something during set up. Below were the items I checked first. After troubleshooting the below list, I was able to select the desired VPC.
- I double checked my VPC and subnet settings to make sure all were in alignment.
- I double checked my security group settings. I said I would set them up later, but forgot. So I added HTTP as an inbound rule.
- I forgot to set up the internet gateway. Once that was set up I needed to add it to the route table. This was the missing piece.
Conclusion
In this article we covered a lot. We learned how to set up a VPC, subnets, internet gateway, auto scaling group, and a load balancer.
We learned how to update a route table and security groups.
Disclaimers
AWS Services and interfaces change frequently. Please note that this article is based on information from November 2023.




