Overview
We start with two pre-configured VPCs:- VPC-A: CIDR block 10.1.0.0/16
Contains an EC2 instance with a private IP address of 10.1.1.13. - VPC-B: CIDR block 10.2.0.0/16
Contains an EC2 instance with a private IP address of 10.2.1.139.

Initial Connectivity Test
Before establishing a VPC peering connection, attempt to ping the EC2 instance in VPC-B from VPC-A. Log in to server one (in VPC-A) and run:Creating the VPC Peering Connection
Follow these steps to configure the VPC peering connection:- Open the VPC peering connections section in the AWS console and click Create Peering Connection.
- Name the connection (for example, “VPC A to VPC B”) for clarity.
- Select the local VPC (the requester) and specify the VPC to peer with. You can create peering connections between VPCs in the same AWS account or across different accounts.
- Since both VPCs are located in the US East 1 region, choose that region and select VPC-B as the accepter.
- Verify that the CIDR blocks do not overlap. VPC peering requires distinct CIDR blocks for proper routing.
- Click Create Peering Connection.

- Select the pending peering connection.
- Click Actions and choose Accept Request.

After accepting the peering request, the connection is established but resources still cannot communicate until the routing tables are correctly configured.
Configuring Route Tables
Even with an active peering connection, neither VPC knows how to route traffic for the other, as explained below:- VPC-A: Has a local route for 10.1.0.0/16 and an Internet Gateway route, but lacks a route for 10.2.0.0/16.
- VPC-B: Lacks a route for 10.1.0.0/16.
- In VPC A’s route table, add a route with the destination CIDR 10.2.0.0/16 and set its target to the VPC peering connection.
- In VPC B’s route table, add a route with the destination CIDR 10.1.0.0/16 and set its target to the same peering connection.



Ensure that the routing changes are applied to the correct route tables associated with the subnets containing your EC2 instances. Misconfigurations can prevent successful connectivity.
Testing Connectivity
After updating the route tables, test connectivity again from server one:Summary
Setting up VPC peering involves:- Sending a peering request from one VPC and accepting it in the other.
- Configuring the route tables of both VPCs to enable proper routing between them.