What is VPC Peering and its key features?

VPC

  1. VPC Peering is a network connection between two Virtual Private Clouds (VPCs).
  2. It allows traffic to be routed privately between VPCs using private IP addresses.
  3. Can be used between VPCs in the same AWS account or different AWS accounts.
  4. No need for VPNs, gateways, or public internet—it's a private network link.
  5. Supports both intra-region and inter-region peering. Key Features
  • Private Communication: Secure communication using private IPs without going over the internet.
  • Low Latency & High Bandwidth: Faster and more efficient data transfer between VPCs.
  • Cost-Effective: No data transfer over the internet = lower costs.
  • Improved Security: Data doesn’t leave the AWS backbone; no public exposure.
  • Easier Resource Sharing: Access services (like databases, EC2 instances, etc.) across VPCs.
  • Simple Setup: No complex setup like VPN tunnels or firewall rules.
  • Cross-Account Support: Collaborate with other AWS accounts easily and securely.
  • Scalability: Connect multiple VPCs for a larger architecture (hub-and-spoke model).

Create your VPCs

Now we create our first vpc(s) named my-vpc-1 and my-vpc-2
and add tags by the name of firstVpc and secondVpc
add IPv4 CIDR 10.0.0.0./16 and 12.0.0.0/26 respectively.
Note: The IPv4 of the vpc(s) must be different from each othes otherwise it is not connected(peering connection is not build between them).
Although a by default vpc is also available in our account.

Image description

Image description
The both vpcs are shown in our second pic.

Create and attach subnets to the VPC(s)

To create new subnet click on the top right corner button create subnet

Image description
Now selecct the vpc in which you want to create the subnet and add your vpc name IPv4 address shown in the pic:

Image description
Now create 4 vpc(s) in your account associated with vpc-1 and vpc-2
named: vpc-1-pub, vpc-1-pri, vpc-2-pub, vpc-2-pri
and associated with vpc1 and vpc2
The total 4 subnets are shown in our account.

Image description

Create Internet Gateways and attach it to the vpc(s)

Click on the internet gateway in the VPC and click on the Create internet gateway button

Image description

and add name of the internet gateway [intenet-1]...... And Click on the Create button
Image description
Now Click on Action button and attach the IGW with your VPC1
Now Create an other IGW named [internet-2] and attach it with the vpc-2.

Image description

Go to Route Tables

Now this time is go to the routtables when you go the route tables options which is under the VPC portion We have already Routables connection just rename and ues it. If the Routables are not availabe the create it first and ues it.
Associate these routables with the vpc(s)
Select the first route table name 1vpc and go to the Subnet accociation option and select the Edit subnet association, the window is change and select the vpc-1 public subnet and associate it.
Image description
Image description

As same as the first association associate the second one vpc2 public subnet

Attach the accessebl ports

  1. Go to the route tables select yor Route table and go to the ROUTES option and click on edits routs

Image description

  1. add changes like access connections internet gateway and save it.

Image description

  1. For verify this whole process go to the VPC and select ane on=f them and check the Recourse Map of this: the connection of the whole circuit is shown in the figure:

Image description

Create VPC Peering Connection

Go to the VPC and Click on the peering connection and create connection:

Image description

Image description

How to Check if VPCs are Connected:
🔍 1. Check VPC Peering Connection
Go to AWS Console → VPC Dashboard → Peering Connections.

Look for the status:

Active = Connection is established.

Pending Acceptance = One side hasn’t accepted the request yet.

📋 2. Check Route Tables
Go to Route Tables in the VPC dashboard.

Select the route table for each VPC.

Look for a route like:

Destination: The CIDR block of the other VPC.

Target: The Peering Connection ID (e.g., pcx-xxxxxxx).

If this route exists in both VPCs, they can talk to each other.

🔧 3. Check Network ACLs and Security Groups
Make sure Security Groups allow inbound/outbound traffic from the other VPC’s CIDR.

Also, Network ACLs must not block that traffic.

🧪 4. Test the Connection
Launch EC2 instances in both VPCs.

Try pinging or SSH from one to the other using private IPs.

If it works, the connection is good

Now in the last step We create 2 EC2 in the public subnets of vpc(s) ans assign public Ips and also enable ssh ports.

Once instances are created connect one instance through shh when it connected the ssh Link of the other instance is paste it is connected with the other instance.
If any error is occure ckeck your steps in vpc