VPC Peering Connections
- VPC peering enables you to establist a network connection b/w two vpc’s in AWS irrespective of accounts/regions to communication using private addresses
- Lets assume we have two ec2 instances in two different vpcs with public ip addresses
- The public ip communication will be possible bcoz it goes through internet
- What if you need to enable private network communication b/w two vpc’s much like how different sites in your organization
- Private ip communication can be allowed b/w any vpcs by using a peering connection
- But ensure the two vpc private ip addresses do not collide
- When you create a peering connection request, a peering connection object is created in your vpc and in other vpc after accepting the request
- Now since we to send the packets from one network to other network, add routes to your route table to send the traffic to peering connection object
Lets create a Peering Connection b/w two vpc’s one in N virginia us-east-1 and other in oregon (us-west-2)
- Create a vpc in us-east-1 with cidr range of 192.168.0.0/16 and ensure you have subnets, igw etc
- Create an ec2 instance in this vpc
- Create a vpc in us-west-2 with cidr range of 10.10.0.0/16 and ensure you have subnets, igw etc
- Create an ec2 instance in this vpc
- Now ping from ec2 instance in us-east-1 to us-west-2 using private ip
- Now lets a peering connection with route tables configure to peering objects and retry the same scenario.
- Lets create a peering request from nvirginia vpc to oregon vpc
- Now lets navigate to vpc of oregon and accept the peering request
- Lets navigate to nvirginia and check the peering request status
- Now lets modify the routes in nvirgina to send traffic to peering connection if the destination cidr range is 192.168.0.0/16
- We have route from nvirginia to oregon, now lets create route from oregon to nvirgina
- Now lets ping from ec2 instance to other ec2 using private ip
- And now i would establish ssh connection from oregon to nvirginia
Exercise:
- Create a vpc peering from aws cli