It establishes connection/communication between different vpc’s. Either you can do in the same region or different region. AWS support peering among AWS accounts.
VPC’s should be a different network, if not you will get overlap error when you create VPC peering.
If you have two vpc’s, 1 to 2 is fine you no need to create 2 to 1 or vice versa.
Once you create peering, you need to add in the route table.
You can do multiple peering connections(more than 2 vpc’s).
VPC Peering Configuration
(here iam going to before peering and after peering connection)
Once login to the console, on search bar type VPC and click on it.
Click on your VPC, select Create vpc, then provide Details like name and IPv2 CIDR
For peering, we require 2 VPC’s, here I am creating one more vpc with the name VPC-2
And creating one subnet on each vpc
Click on a subnet, then click on Create subnet, give details like subnet name, select your vpc and CIDR.
Once more subnet on 2nd VPC
Next step, create Internet gateway then attach to VPC
Do the same thing on to the 2nd VCP also
Once create Internet gateway, attach to the route table, here I am attaching to main route table (main route table, whenever you create vpc it will create one route table)
Do the same thing to the other route table
Create once instance in each network
Selecting one VPC among different VPC, subnet and public IP.
I have given 2 rules, RDP and ICMP
And one more instance with a different network, with the same setup as we opted above.
Connect both the instance and ping
It’s not pinging because those are a different network, as of now we didn’t do peering also.
Now, will do peering connection.
Go to peering connection, click on create peering connection
Then it will ask you name, requester, and accepter, then click on create
Once click on create, and you need to accept the request
Go to route table add peering connection on both the route table.
On another route table