VPC Peering
A VPC peering connection is a networking connection between two VPCs that enables you to route traffic between them using private IPv4 addresses or IPv6 addresses. Instances in either VPC can communicate with each other as if they are within the same network. You can create a VPC peering connection between your VPCs, or with a VPC in another AWS account. The VPCs can be in different regions (also known as an inter-region VPC peering connection).
Let’s take an example:
Step: 4 Now switch region to OHIO
Step: 5 Create Internet gateway name VPC-B IGW and attach it to VPC B
Step:6 Switch to N. California
Step:7 Create an internet gateway and attach it to VPC C
Step:8 Check the route Table So that u r going with the flow
Step:9 Rename the default route table and add internet gateway
step:11 Do the subnet association
Step: 12 Switch to Ohio and do the same activities for VPC-B
Step:13 Switch to N. Virginia and rename route table, This Subnet is private and we will not have any internet gateway routing.
Step: 15 Create a routing table:
Step: 16 Do subnet association
Step:18 Now in the same region, N. Virginia, go to vpc peering and create peering connection
Step:20 Now go to Ohio and accept the peering request
Step: 21 Do the same peering for VPC C of N. California.
Step: 22 After this, we need to add routes to the Route table, switch to N Virginia and do the routes association.
Step:23 Now modify the route for VPC subnet Y.
Step: 26 Now go to Ohio and we need to modify the routing table for VPC B to add peering connection route.
Step: 27 Switch to N.California and do the same for it.
Step: 28 Now Launch EC2 in N.Virgina using subnet X
Step: 29 Keep traffic in Security grp as ssh only
Step: 30 Now launch another EC2 in subnet Y with a security group as ssh only.
Step: 31 Now launch EC2 in Ohio with auto-assign public IP enable and ssh as a security group.
Step: 32 Create another public instance in N. California with ssh as security grp
Step: 33 Keep traffic in Security grp as ssh only
Step: 34 Now launch another EC2 in subnet Y with a security group as ssh only.
Step: 36 Now launch EC2 in Ohio with auto-assign public IP enable and ssh as a security group.
Step: 37 Create another public instance in N. California with ssh as security grp
Step: 38 Now check the connectivity via ssh.
========================================
To Delete these setups we need to follow these steps:
- Delete EC2.
- Delete NAT Gateway.
- Delete EIP.
- Delete IGW.
- Delete Subnets.
- Delete Route Table (one RT will be left because that RT is the default).
- Delete VPC.