Creating a VPC

So, first you gotta know what's a VPC.

VPC stands for Virtual Private Cloud and it allows you to pretty much isolate your resources in the cloud environment and also configure the inbound/outbound connections .... everything that you'd do when you set up a physical server.

In this blogpost, we will be looking at how to create a VPC.


This is how our architecture is gonna be!


Step 1: In the left pane, scroll down or search for "VPC" in the search bar.

 Then, you will see we have no VPC's created



(Note: If you already have created EC2 instances, then you might find some VPCs in there. But in this blogpost, we'll be doing from ground up, so yeah :D)

Step 2: Click on "Create VPC"

Step 3: Give your VPC a name and the IPv4 CIDR address block and let the other settings remain as they are, and then click on "Create VPC"



Then you would have VPC created in no time and you can find your newly created VPC in the "Your VPCs" list.




Step 5: Click on "Subnets" under VPC in the left pane or just search for "Subnets" and click on it.
            As you can see, there aren't any subnets within this VPC. So let's create some!
            Click on "Create Subnet" to do that.




Step 6: Then select the VPC you're wanna create the subnets within and create how many subnets you                 want by clicking on "Add New Subnet" button.
             You'd have your subnets created finally!










Now to take things a step further, let's create a IGW (Internet Gateway) that can allow a EC2 machine that we're gonna create in the "PublicSubnetA" (in my case) to be accessed from the Internet.
To make this blogpost, I've already created an EC2 machine in the "PublicSubnetA" in the "DemoVPC"


If you haven't created one yet, you can create one as I've did, and just make sure that you've enabled the "Auto-Assign Public IP" option.


Step 7: Now go to VPC > Internet Gateway or just search for it and you'll find the search result under 
            "Features". Click on "Create Internet Gateway" to create one.

Step 8: Just give the IGW a name, and create one.



Step 10: Attach the IGW to the VPC you want to, by going to Actions > Attach to VPC

Step 11: Select the VPC you wanna attach the IGW to, and then click on "Attach Internet Gateway"



Step 12: Then, you need to create a route table, so the EC2 instance can send/receive traffic to/from the                Internet through the IGW. But there needs to be a router for this to happen.
              So let's create a router and its routing tables now, shall we? 
              Click on "Route Tables" under Virtual Private Cloud and then "Create route table"


Step 13: Give your route table a name and select the VPC you wanna assign the route table to.Click on                "Create route table" to create one.
 

Step 14: Let's assign our "PublicSubnetA" to the "PublicRouteTable" by selecting that route table.
              Go to Subnet Associations > Edit Subnet Associations.



Step 15: Assign the "PublicSubnetA" by ticking it and clicking on "Save associations" .





Step 16: Add a route for the EC2 machine by go to Routes tab > Edit routes.



Step 17: Now let's add a route that matches all other traffic except the ones for 10.0.0.0/16 to be routed  
               by the IGW we've created. Click on "Save Changes" .



Step 18: Now you will be able to access your EC2 machine from the Internet!






























 



Comments

Popular posts from this blog

Mounting an EBS volume to an EC2 Linux instance