Create Custom VPC IN AWS

Create Custom VPC IN AWS

Create Public and Private Subnets and launch EC2 on It

VPC - Virtual Private Cloud

Amazon Virtual Private Cloud (Amazon VPC) enables you to launch AWS resources into a virtual network that you've defined. This virtual network closely resembles a traditional network that you'd operate in your own data center, with the benefits of using the scalable infrastructure of AWS.

  • Amazon VPC is the networking layer for Amazon EC2.

The following are the key concepts for VPCs:

Virtual private cloud (VPC) — A virtual network dedicated to your AWS account.

Subnet — A range of IP addresses in your VPC.

Route table — A set of rules, called routes, that are used to determine where network traffic is directed.

Internet gateway — A gateway that you attach to your VPC to enable communication between resources in your VPC and the internet.

CIDR block —Classless Inter-Domain Routing. An internet protocol address allocation and route aggregation methodology.

1.Create VPC

  • So We will going to create VPC With the Below Network value 10.0.0.0/16
  • Open VPC Console on AWS.

image.png

  • Config Screen

image.png

  • When you create a VPC a Route Table, Network ACL, and Security Group are automatically created.

  • Subnets or Internet Gateways are NOT automatically created, so we’ll create those below.

2.Create SubNets

image.png

  • We want to create the 2 subnets.
  • 1 subnet is public other 1 is private
  • The below values i have assigned to my subnet.

Public-Subnet
Availability zone : ap-south-1a IPv4 CIDR block : 10.0.1.0/24

Private-Subnet Availability zone : ap-south-1b IPv4 CIDR block : 10.0.2.0/24

Public Subnet

image.png

image.png

Private Subnet

image.png

image.png

  • Now Our Subnet screen looks like.

image.png

3.Create Internet gateway

  • Now we want to Create Internet gateway and attach it to custom VPC so that the VPC Will get the internet.

image.png

  • Give the Name for it.

image.png

  • And attach to our newly created Custom VPC.

image.png

image.png

4.Create new Route Table

  • Now we want to create route table to route the traffic between subnets,internetgateway to public.

image.png

image.png

  • Now we need to give the Route Table (Custom Route) a route to the internet. Edit routes.

image.png

  • And add new route sourece is 0.0.0.0/0 to Newley created Internet gateway.

image.png

  • Lets associate a subnet we want to have internet access by going to the Subnet Associations and clicking on Edit.

image.png

  • I am onlyasocitae my public subnet

image.png

  • Now Our Public Subent have internet access and private subnet not having the internet access.
  • After that we wanto modify the auto assign public ip settings to our public subnet.

image.png

image.png

  • That's all Guys We have Successfully create one Full Functional Customized VPC.

5.Test The Custom VPC

  • Now we will going to check our Custom VPC is working Properly or have any issue on the connectivity.

  • For that We are going to launch Two EC2 Instance on that VPC.

  • One instance in Public Subnet other one is private subnet.

Public Subnet associated Instance

  • Here I Have selected Custom VPC and choose public subnet.

image.png

  • Then launch the instance with all the default values.

Private Subnet associated Instance

  • Here i have selected Custom VPC and choose private subnet.

image.png

  • Then launch the instance with all the default values.
  • Ok.Now we going to connect the instance via SSH.

Here Two EC2 Instacnes are running one is public other one is private.

image.png

See here there is no Public IP assigned for Private EC2 instance.

Public Subnet Instance

image.png

  • Connect Private instance through Public Instance
  • So i copied the .pem file to public instance.

image.png

  • Now i am connected the public instance via ssh and then connect private instance from that.

image.png

  • Yeah its connected and working perfectly.

That's all guys... I have successfully created the Custom-VPC and configured and tested it.

Did you find this article valuable?

Support venket's b log by becoming a sponsor. Any amount is appreciated!