AWS
You are a network engineer tasked with creating a cloud network. You have heard of AWS and know that it is the most popular cloud provider. You also know that AWS has a service called VPC. You are unsure what that means, but you know that you need to create a VPC for your staging and production instances. So, what do you need to know?
VPC stands for Virtual Private Cloud, which is a virtual network dedicated to your AWS account. It is logically isolated from other virtual networks in the AWS Cloud.
A subnet is a range of IP addresses in your VPC. You can launch AWS resources into a subnet that you select.
An internet gateway is a horizontally scaled, redundant, and highly available VPC component that allows communication between instances in your VPC and the internet.
EC2 stands for Elastic Compute Cloud, a web service that provides secure, resizable computing capacity in the cloud. Think of it as a virtual machine in the cloud.
The rest is basic networking concepts. You need to create subnets, route tables, and security groups. You also need to create network ACLs.
Simple enough? Let’s go build out our VPC.
Let’s have a look at our network diagram. We have a VPC with two subnets—one public and one private. We also have an internet gateway to configure and create routes between our subnets.
First, let’s create a VPC:
We created a VPC with a Classless Inter-Domain Routing (CIDR) block of /16, meaning that we have 65,536 IP addresses. We are going to use 256 addresses for each subnet.
These concepts should not be new to you. You probably have heard of CIDR blocks and subnetting if you come from a networking background. If you haven’t, may I suggest that you check out the CCNA certification course on Cisco U.
Now that we have our VPC created, let’s create our public subnet.
A public subnet is a subnet that has a route to the internet. It is usually used for resources that need access from the internet. In this case, the resource will be an EC2 instance.
All right, let’s create our public subnet:
A few things to note:
OK, that was not that bad. Let’s do the same with our private subnet.
Having a private subnet allows us to have resources to restrict internet access, which is excellent for security—maybe a Vault server that houses all secrets and tokens. You don’t want that to be accessible from the internet.
All right, let’s configure our private subnet:
Sweet! we now have a private subnet. Let’s move on to the next step.
Our next steps are to create an internet gateway and configure our route tables to make our subnets reachable from the internet.
Before we get started on building our internet gateway, let’s talk about what an internet gateway is:
But before we start, let’s change the settings of our CiscoU-Public-Subnet to allow auto-assign of public IPv4 IP addresses.
Select CiscoU-Public-Subnet:
Now let’s go ahead and build our internet gateway:
Great! Let’s attach it to our CiscoU-VPC:
OK, perfect, we’re almost there. We now have a way to get public IP addresses to our instances, but we don’t have a route created to direct traffic from our public subnet to the internet gateway.
Let’s create a route table and add a route to our internet gateway.
A route table contains a set of rules, called routes, that are used to determine where network traffic is directed. It is no different from a routing table in a router. As a network engineer, you should be familiar with the concept.
Let’s create a route table for our CiscoU-Public-Subnet:
You now have a way to direct traffic from your public subnet to the internet gateway, but we have to define a route to do that.
Let’s define a route to our internet gateway:
Notice that we have a default route to resolve all traffic to the local VPC. This is a default route that was created when we created our VPC. 3.Let’s create a catch all route that will allow us to reach the public internet. - Destination: 0.0.0.0/0 - Target: Internet Gateway - Select CiscoU-IGW. 4. Click Save routes.
Next, we need to associate our CiscoU-Public-RT to our CiscoU-Public-Subnet.
Voilà! We now have a public subnet that has a route to the internet.
Let’s attach some computing to our newly created network.
EC2 is a web service that provides secure, resizable computing capacity in the cloud. Think of it as a virtual machine in the cloud.
EC2 can help with:
Let’s launch an EC2 instance in our CiscoU-Public-Subnet.
Navigate to the EC2 service:
Here is where we will configure our EC2 instance:
Give your instance a name: CiscoU-EC2-Pub
Select an Amazon Machine Image (AMI): Amazon Linux 2023 AMI
Architecture: 64-bit (x86)
Instance Type: t2.micro free tier eligible
Key pair: Create a new key pair
In the Network Settings section, click Edit. Let’s make sure that we are launching our instance in the right subnet:
Add another rule to allow SSH traffic:
The rest of the settings can be left as is.
Scroll down and click Launch instance.
Once launched, click View All Instances to see your instance.
Next, let’s launch an EC2 instance in our CiscoU-Private-Subnet.
Here, we are going to create an EC2 instance in our CiscoU-Private-Subnet. This is a subnet that does not have a route to the internet. We will access this instance from our CiscoU-EC2-Pub instance.
Click Launch Instance:
That was a lot of work. We are almost there! Let’s use SSH into our instances.
First, we’ll use SSH into our CiscoU-EC2-Pub instance. From your Instances view, right-click CiscoU-EC2-Pub, and then click Connect:
ssh -i "CiscoU-EC2-Key-Pub.pem" ec2-user@54.191.237.93
.A couple of things to note:
chmod 400 CiscoU-EC2-Key-Pub.pem
to change the permissions of your key pair.Now that we are in our public instance, let’s set it up to use SSH into our private instance that’s not accessible from the internet.
In your current terminal, run the following commands:
vi CiscoU-EC2-Key-Priv.pem
to open a new file.i
to enter insert mode.CiscoU-EC2-Key-Priv.pem
in a text editor and copy the contents of the file.esc
to exit insert mode.:wq
and enter
to save and exit.chmod 400 CiscoU-EC2-Key-Priv.pem
.ssh -i "CiscoU-EC2-Key-Priv.pem" ec2-user@10.0.2.160
.You should now be in your private instance. Woo hoo!
Note: If you’d like to learn more about using Vim, you can find an introductory tutorial here or a more intermediate tutorial here
Congratulations! You are on your way to becoming a cloud networking expert.
We learned a lot here. Let’s summarize what we did:
All these are fundamental building blocks of cloud networking, but they are not so different from what we are used to in the networking world.
What’s next? You can start by checking out the following: