How to Create AWS VPC and Validate Connection

Binal Kagathara
4 min readJun 11, 2021

--

Pre requisites:

  • AWS Account
  • Basic knowledge of EC2
  • Networking knowledge

Virtual Private Cloud(VPC)

  • Amazon VPC lets you provision a logically isolated section of the AWS cloud where you can launch AWS resources in a virtual network that you define.
  • You have complete control over your virtual networking environment, including a selection of your own IP address ranges, creation of subnets, and configuration of route tables and network gateways.
  • You can also create a hardware Virtual Private Network (VPN) connection between your corporate datacenter and your VPC and leverage the AWS cloud as an extension of your corporate data center.

Main Components of Amazon VPC :

  • A Virtual Private Cloud: A logically isolated virtual network in the AWS cloud. You define a VPC’s IP address space from the ranges you select.
  • Subnet: A segment of a VPC’s IP address range where you can place groups of isolated resources.
  • Internet Gateway: The Amazon VPC side of a connection to the public Internet.
  • NAT Gateway: A highly available, managed Network Address Translation (NAT) service for your resources in a private subnet to access the Internet.
  • Route Table: A route table contains a set of rules, called routes, that are used to determine where network traffic from your subnet or gateway is directed.
  • CIDR: Classless Inter-Domain Routing

Let’s Start the Demo,

Step-1: Create a VPC

  1. Login to your AWS Console.
  2. Create your VPC with Valid CIDR and name.

Step-2. Create 2 Public Subnet & Create 2 Private Subnet

  1. Click Subnet and create your Subnet with:
  2. Public Subnet 1 and Public Subnet 2 valid Name & VPC.
  3. Valid Subnet range which is valid IPv4 CIDR Block.
  4. Repeat steps 2 & 3, with Private Subnet too.

Step-3. Create IGW (Internet Gateway) & Attach to the VPC

  • Once IGW create, then attached this IGW in VPC

Step-4. Create Public and Private Route Table

Main route table — The route table that automatically comes with your VPC. It controls the routing for all subnets that are not explicitly associated with any other route table.

Custom route table — A route table that you create for your VPC.

  1. Create a Route table in the same VPC.
  2. Make sure you select the right VPC and give a proper tag.

Step-5. Add IGW in Public Route table (0.0.0.0/0)

  • Click on the Public route table and click on the edit button.
  • Click on Add route from 0.0.0.0/0
  • Select Internet gateway from Target drop-down menu.
  • Click on save the routes.

Step-6. Add Public Subnet (1a & 1b) in Route table

  • Edit the Subnet Association.
  • Select the Public Subnet checkbox.
  • Click on the Save button.

Step-7. Create a NAT Gateway in Public Subnet

  • Select a Public Subnet
  • Create a new Elastic IP and associate
  • click on Create NAT Gateway

Step-8. Add NAT GW into the Private Route Table

  • Click on the Private route table and click on the edit button.
  • Click on Add route from 0.0.0.0/0
  • Select NATgateway from Target drop-down menu.
  • Click on save the routes.

Step-9. Add Private Subnet in Private Route Table

  • Edit the Subnet Association.
  • Select the Private Subnet checkbox.
  • Click on the Save button.

Step-10. Launch EC2 in this VPC & Validate your Connection

  • Download the putty & PuttyGen software to your windows server.
  • Change your .pem file to .ppk extension.
  • Connect from you putty

Once connected to your public instance you can copy your pem file to this instance and run the following command to connect to your private instance.

chmod 400 file_name.pem

ssh — i file_name.pem ec2-user@your_private_ip

Then try to connect with the internet in a private instance.

yum update -y

If you are able to connect with a Private instance and be able to update the instance. This means you have successfully Created your VPC and Public & Private subnets with the proper connection of your IGW/ NGW & Route Table.

Bravo! You made it.

Here are some more blog about AWS,

https://binalkagathara.medium.com/

--

--

Binal Kagathara
Binal Kagathara

Written by Binal Kagathara

DevOps Engineer| AWS Certified Solution Architect - Associate | IT student

No responses yet