Your first  VPC ( Virtual Private Cloud) via AWS VPC

Your first VPC ( Virtual Private Cloud) via AWS VPC

Table of contents

No heading

No headings in the article.

Good evening guys, Jordan here. Today I'm going to introduce you guys to a very simple, yet crucial component of the cloud, the VPC !!!!!

Alright so let's start with some definitions. A VPC or virtual Private Cloud is one of AWS most used offerings. AWS VPC is basically a conceptually separated area of the Amazon Web Services (AWS) cloud where you may create your very own virtual network inside of the bigger Amazon cloud system, and deploy any other AWS resources you may like. This then provides you total control over your virtual environment in which you might even access resources and apps using both IPv4 and IPv6. Here is a little diagram to illustrate the later. Screen Shot 2021-11-10 at 4.21.23 PM.png

In this blog, I'm going to walk you through the process of creating your own VPC within AWS, assuming you already have an account. if you don't, here's a link to a tutorial that'll help you get that done.

youtube.com/watch?v=nIyhr4vCGuc

It's very important that you do all of this in one of your user accounts as it's considered best practice.

Alright! let's get started!

In the management console of your user account, we're going to select the Service tab and display the drop down menu. Once that is done, let's click on VPC. Next, click create VPC and fill in the prompts for your Name tag ( it's important to stay consistent so remember this name tag) and IPV4 CIDR block. Use 10.0.0.0/16 for your IPV4 CIDR . Next, click Create VPC.

Next stop, we're going to create a two public subnets. In your VPC, a subnet is a range of IP addresses. AWS resources can be launched into a specific subnet. For resources that must be connected to the internet, use a public subnet, and for resources that will not be connected to the internet, use a private subnet. Here, we will create two public subnets that will each reside in separate availability groups.

In the left navigation plane , click on Subnets, and next click Create subnet. We're then prompted to enter the VPC ID and Subnet name, to which we'll will enter My VPC and Public subnet 1 respectively. Next, for the availability zone, we'll select the first AZ in the list, and for the IPv4 CIDR block, we'll enter 10.0.1.0/24, and hit create subnet. Select your Public Subnet 1 and in the Actions menu, select Modify auto-assig IP settings. Check mark on Enable auto-assign public IPv4 address and click Save. This will provide a public Ipv4 address for all the instances launched in the subnet automatically.

Let's now create our second public subnets. Same procedure as before, but now name it Public subnet 2 and pick the second availability zone in the list. The IPv4 CIDR block here will now be 10.0.2.0/24. Select your Public Subnet 2 and in the Actions menu, select Modify auto-assig IP settings. Check mark on Enable auto-assign public IPv4 address and click Save.

Okay, let's pause for a second here and let me tell you guys about Internet gateways. An Internet gateway is a VPC component that allows communication between instances in your VPC and the Internet. It is horizontally scaled, redundant, and highly available. As a result, your network traffic is not exposed to any threats of availability or bandwidth limits. An Internet gateway has two functions: it acts as a destination for Internet-routable traffic and it performs network address translation (NAT) for instances with public IPv4 addresses.

So now that you know that, let's create one.

Back in the left navigation pane, you'll see Internet Gateways. Click on it. Next, click on Create Internet gateway and configure it as follows:

Name tag: My Internet Gateway.

Now click on create Internet gateway.

Next, let's go to the Actions menu and select Attach to VPC. Naturally, we'll use the VPC we created. So, for available VPCs, choose My VPC, and click on Attach internet gateway. This will attach the internet gateway we created to our VPC.

Now I know I just said we needed the internet gateway to connect our instances to the internet. Turns out we need to go a step further. We'll need to tell our instances in our public subnet how to get to the internet. For that, we'll need to create a Route Table, add routes, and associate those to the public subnets.

You're probably wondering," what's a routing table, Jordan?? ". A route table must be connected with each subnet in your VPC. The routing of network traffic is determined by a route table. A subnet can only have one route table at a time, however, the same table can be used by many subnets. 1*VKTHtHwo3pUxeDP0ZmrOoA.jpeg

In the left navigation pane, click Route Tables. There will be one default route table associated with the VPC, My VPC. This will route traffic locally, but you'll need to create an additional Route table to route traffic to your internet gateway. Click on Create route table, and under Route table settings configure as follows:

Name - optional: Public Route Table

VPC: My VPC

Click on Create Route Table.

It's worth noting that there's one route in your route table that permits traffic within the 10.0.0.0/16 network to pass within the network but not outside of it. To enable public traffic, you'll need to create a new route.

Click Edit routes, then Add route and we'll put 0.0.0.0/0 as Destination. For Target, we'll select Internet gateway in the drop down and select the displayed internet Gateway id. Click Save changes. Next, click on Subnet associations tab, and under section Explicit subnet association, click Edit subnet associations. Select your subnet 1 and 2 ( remember the ones you created at the beginning), and click save assocaitions.

Congratulations, the two subnets you create are now public and able to connect to the internet.

This is pretty much it guys. Now all you have to do is configure your security groups how you please when its time to add some instances in your VPC !!!

I hope you found this fun and congratulations again on creating your first VPC in the cloud!! If you have any issues or need clarifications, drop them in the comments, i'll be more than happy to help!!

Down below i attached some links and references for additional resources:

AWS VPC: docs.aws.amazon.com/vpc/latest/userguide/wh..

Internet Gateways: docs.aws.amazon.com/vpc/latest/userguide/VP..

Route Tables: docs.aws.amazon.com/vpc/latest/userguide/VP..

Jordan.