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:

Architecture
Step-1
Step-2
Step-3

Step: 4 Now switch region to OHIO

Step-4

Step: 5 Create Internet gateway name VPC-B IGW and attach it to VPC B

Step-5

Step:6 Switch to N. California

Step-6

Step:7 Create an internet gateway and attach it to VPC C

Step-7

Step:8 Check the route Table So that u r going with the flow

step-8 Check here

Step:9 Rename the default route table and add internet gateway

Step-9
step 10

step:11 Do the subnet association

step-11

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-13
step-14

Step: 15 Create a routing table:

Step-15

Step: 16 Do subnet association

Step-16

Step:18 Now in the same region, N. Virginia, go to vpc peering and create peering connection

Step-18
step-19

Step:20 Now go to Ohio and accept the peering request

Step-20

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-22

Step:23 Now modify the route for VPC subnet Y.

Step-24

Step: 26 Now go to Ohio and we need to modify the routing table for VPC B to add peering connection route.

Step-26

Step: 27 Switch to N.California and do the same for it.

Step-27

Step: 28 Now Launch EC2 in N.Virgina using subnet X

Step 28

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-30

Step: 31 Now launch EC2 in Ohio with auto-assign public IP enable and ssh as a security group.

Step-31

Step: 32 Create another public instance in N. California with ssh as security grp

Step-32

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-35

Step: 36 Now launch EC2 in Ohio with auto-assign public IP enable and ssh as a security group.

Step-36

Step: 37 Create another public instance in N. California with ssh as security grp

Step-37

Step: 38 Now check the connectivity via ssh.

========================================

To Delete these setups we need to follow these steps:

  1. Delete EC2.
  2. Delete NAT Gateway.
  3. Delete EIP.
  4. Delete IGW.
  5. Delete Subnets.
  6. Delete Route Table (one RT will be left because that RT is the default).
  7. Delete VPC.