An AWS (Amazon Web Services) VPC (Virtual Private Cloud) peering connection is a networking connection between two VPCs that enables us to route traffic between them using private IPv4/IPv6 addresses. Instances in either VPC can communicate with each other as if they are within the same network. We can create a VPC peering connection between our own VPCs, or with a VPC in another AWS account. The VPCs can be in different regions (inter-region VPC peering connection).
Create VPC Peering Connection (Initiate from the Requester — VPC 1)
To initiate the VPC Peering from VPC 1 (for ex. London), we’ll follow these steps.
Step 1: Login to AWS Console.
Step 2: Search VPC from Services or we can find VPC in “Networking & Content Delivery” section.
Step 3: Go to VPC -> Peering Connection.
Step 4: Select “Create Peering Connection”.
Step 5: Provide a name tag to the Peering Connection.
Step 6: Select a local VPC (Requester) to peer with. (Local VPC to initiate the request), it’ll show us the CIDR Block associated with the local VPC.
Step 7: Select another VPC to peer with. Here, we can select a VPC from the same account or another account. We can also select from the same region and from another region (inter-region VPC Peering Connection) as well.
Step 8: Provide target VPC (Accepter) ID and click on Create Peering Connection.
Now, we can see the Peering Connection is initiated and status is “Pending Acceptance”, we need to accept the request on destination VPC (VPC 2).
Accept VPC Peering Connection (accept from the Accepter — VPC 2)
We can see the same status on Accepter VPC (VPC 2) as well.
Step 1: Select the pending VPC Peering Connection
Step 2: Select “Accept Request” and Accept Request confirmation comes.
VPC Peering Connection is active
We can check that the status is now active on both VPCs.
Some additional steps to complete the connection
We’ve completed the Peering Connection procedure but still, we need to follow some additional step to complete the connectivity between 2 VPCs.
Step 1: Create Routes on both ends.
On VPC 1, we need to provide CIDR for destination VPC (VPC 2) and target should be “Peering Connection”. Click on “Save routes”.
On VPC 2, we need to provide CIDR for destination VPC (VPC 1) and target should be “Peering Connection”. Click on “Save routes”.
Step 2: Allow respective CIDR on the “Security Group” of particular service so that we can establish the connection to that service. I allowed CIDR on destination EC2 virtual machine’s Security Group.
Step3: Ping destination service (EC2) from source to check if everything is configured properly.
Thank you