Hi Friends,
Let us learn about the basics of VPC peering, limitations of vpc peering and how can we create a vpc peering connection between two VPCs.
What is VPC peering
A VPC peering connection is a networking connection between two VPCs that enables you to route traffic between the VPCs using private IPv4 addresses or IPv6 addresses.The instances in these VPCs can communicate each other. VPCs can be created within the same AWS Account or with another AWS Account. AWS doesn't charge you for creating a Peering connection however you need to pay for the traffic flow between the VPCs.
Let us assume that you have created the VPC peering for your VPCs residing in the same region and in the same account. You are trying to connect between instance A in VPC 1 and instance B in VPC 2. If both the instances are in the same AZ, then the connectivity charges is zero as your traffic is not flowing outside of the AZ.
Leverage Transit gateway if you need multiple VPCs to interconnect rather than creating peering connections.
Limitations of VPC Peering
VPC peering doesn't support transitive peering. :- Let us assume that you have three VPCs. You had created a peering between "VPC A and VPC B" and "VPC B and VPC C". Don't expect that you can connect an instance in VPC A to an instance running in VPC C.
Edge to Edge Routing is not supported :- Let us assume that you have created a peering connection between VPC A and VPC B. VPC A has connected to an internet gateway or a VPN gateway. The instances in VPC B, cannot use an Internet gateway or VPN gateway connected to VPC A for the traffic Flow.
Overlapping CIDR blocks are not supported :- Your VPCs should not have the same or overlapping IP Address ranges.
You cannot create multiple VPC peering connections between 2 VPCs at the same time.
-
Mind your VPC Peering connection quotas
Creating a VPC Peering Connection
In this blog, I am going to create a VPC peering connection between my two VPCs located in the same region and same account.
Navigate to the AWS portal--> VPC
Search for Peering connections under the virtual private cloud section.
- The peering connection page will appear. Click on "create peering connection" from the top right corner.
- In the create peering connection page, provide the details as below
Name of your peering connection
The VPC ID of the requester
Specify the AWS Account of the 2nd VPC to which you need to create the peering connection
1.Specify the AWS Region of the 2nd VPC to which you need to create the peering connection
The VPC ID of the Accepter
Provide tags if any and click on Create peering connection
Once you create the peering connection, you need to accept the peering connection. If you are connecting to a VPC in a different account, navigate to that account and accept the peering connection request
Verify the settings and click accept request
You will get a confirmation once the request has been accepted.
s Create Route Table
An important activity to perform as part of the VPC peering activity is to edit your route tables and add the cross VPC routing.
The below diagrams shows the routing tables created for my VPCs.
s Testing the connection
Our VPC peering is done, now it time to test it. I had connected to VM1 in VPC A and tried an ICMP ping to my VM2 located in VPC B. Note: I have enabled security group inbound rules for the ICMP traffic flow._
Hope this short blog helps you to understand what is VPC peering and how to create a VPC peering connection.
Top comments (0)