VPC Peering

Basics of VPC Peering – Amazon Virtual Private Cloud

Exam Objective

Virtual Private Cloud (VPC) is a separate isolated region that is used to host AWS resources. The topic “VPC Peering” addresses the Design and Implementation of AWS Networks as highlighted in the AWS Blueprint for the exam guide.

Start AWS Certified Advanced Networking Specialty Free Test Now

What is VPC Peering?

VPC Peering is allowed for the connection of two VPC’s such that the instances in the VPC can communicate with each other. The VPC’s can be part of multiple accounts, ut must be in the same region.

Let’s go ahead and see how to work with VPC Peering.

Implementation of VPC Peering

Let’s follow the below steps to see how VPC Peering can be implemented.

The first few steps will involve creating 2 VPC’s first before peering them together.

Step 1) Log into your AWS Console. Choose the relevant region and go to the VPC section under Networking and Content Delivery section.

VPC Peering

Step 2) Create one VPC with a name tag of VPCA and CIDR block of 10.0.0.0/16

Create VPC

Step 3) Create another VPC with a name tag of VPCB and CIDR block of 20.0.0.0/16

CIDR Block

Step 4) Now let’s create subnets in each of these VPC’s. In VPCA let’s create a subnet with a Name tag of SubnetA with a CIDR block of 20.0.1.0/24

Amazon VPC

Step 5) Nowlet’s create a subnet in VPCB. In VPCA let’s create a subnet with a Name tag of SubnetB with a CIDR block of 10.0.1.0/24

Virtual Private Cloud

Also Read: How to Improve Connectivity and Secure your VPC Resources?

Step 6) Now we are going to launch instances in both of the subnets. We want to ensure that both subnets get Public IP addresses, so enable them for the each subnet accordingly.

Amazon Virtual Private Cloud

Ensure the Auto-assign IP settings is enabled for both subnets

VPC Connection

Step 7) Now let’s create a VPC Peering connection between both of the VPC’s

On the left hand side, go to Peering connections

VPC Peering Connection

Step 8)In the next screen go ahead and click on Creating a new peering connection.

For the peering connection, give a name tag for the connection. And then put the requester of the VPC as VPCA

Create Peering Connection

Then choose the other VPC as the VPC to Peer with and then click on Create Peering connection.

Create VPC Connection

Step 9) Now the VPC Peering connection you can see that the Status is Pending Acceptance

VPC Peering Connection

Choose the connection, click on Actions->Accept Request

VPC Peering

And then accept the request

VPC Peering with AWS

Once done, the connection will be in the Active State

Step 10) Now we need to modify the route tables of both the VPC’s to ensure that communication can flow via the VPC Peering connection.

So in the Route Table for VPC B, we need to add the destination for the CIDR of VPC A as the destination and the VPC Peering connection as the target.

VPC Peering Route Table

We need to do the same thing for the Route table of VPC A

VPC Peering Route Table

If you want to connect to anyone of the instances in the VPC via the internet, ensure that the internet gateway is attached to the Route table as well.

VPC Peering Route Table

Step 11) Now it’s time to launch instances in each VPC.

So here we have 2 servers, one is ServerA which is launched in VPCA and ServerB launched in VPCB

VPC Peering

Now we are going to connect to ServerA in VPCA and then ping ServerB. The private IP of ServerB is 10.0.1.138.

Amazon VPC

Since we are going to use the ping command , ensure that the Security Group for both instances have the security group modified to allow the ICMP protocol.

VPC Peering with AWS

Once all of this is in place, you will be able to ping ServerB from ServerA.

Amazon Virtual Private Cloud

Also Read: Introduction to Elastic Network Interface

Important Points to Remember

  • Transitive VPC Peering is not allowed. Let’s say you have the following VPC’s peered.

So here we have VPCA peered to VPCB and VPCB peered to VPCC. This does not mean that VPCA can communicate with VPCC through VPCB.

For VPCA to communicate with VPCC, there has to be one explicit VPC Peering connection from VPCA to VPCC as shown below

VPC Peering Connection

  • You are not allowed to create a VPC peering connection between VPCs with overlapping or matching IPv6 or IPv4 CIDR blocks
  • It is not possible to create a VPC peering connection between VPCs present in different regions
  • Only one VPC peering connection is possible between two VPCs at a time
  • In case of following VPC peering connections, it is not allowed to extend the peering

(a) If corporate network have VPN or AWS Direct connection

(b) If internet is connected through a NAT device in a private subnet

(c) If internet is connected via an internet gateway

(d) VPC endpoint to an AWS service, such as an endpoint to Amazon S3

Final Words

The aim of Whizlabs is to help the individuals in their journey of preparing and passing AWS Certified Advanced Networking Specialty certification exam. We deliver the best and high-quality preparation material to evolve professional career. Whizlabs content is prepared by the industry experts who have a great knowledge and passion for cloud computing. We are continuously growing our cloud expert’s community.

About Pavan Gumaste

Pavan Rao is a programmer / Developer by Profession and Cloud Computing Professional by choice with in-depth knowledge in AWS, Azure, Google Cloud Platform. He helps the organisation figure out what to build, ensure successful delivery, and incorporate user learning to improve the strategy and product further.

2 thoughts on “Basics of VPC Peering – Amazon Virtual Private Cloud”

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top