Peering is a method that allows two networks to connect and exchange traffic directly without having to pay a third party to carry traffic across the Internet.
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.You can establish peering relationships between VPCs across different AWS Regions (also called Inter-Region VPC Peering).
First we need two VPC on same or different account so click on link https://www.hackerxone.com/blog/how-create-vpc-subnets-amazon-web-serviceaws for how to create VPC.
- Login to aws portal.
- Click on Services.
- Under Networking & Content Delivery select VPC.
- Click on VPC Peering Connections.
- Click on Create Peering Connections.
- Provide Peering connection tag name.
- Select VPC as a Requester in your account with which you want to create the VPC peering connection.
- Select another VPC as a accepter in your account or another account & same or different region
- Click on Create Peering Connection.
- After sometime Peering Connection is created successfully.
- Click on OK then go to VPC Peering Connection console page.
- New Peering Connection is there with the tag name we provide.
Create VPC Peering Connection using Shell
- Setup aws-cli on your system so click on link https://www.hackerxone.com/blog/how-install-configure-aws-cli-ubuntu-1804
- Run the following command:
To create a VPC peering connection between your VPCs
aws ec2 create-vpc-peering-connection –vpc-id vpc-requester-id –peer-vpc-id vpc-accepter-id
To create a VPC peering connection with a VPC in another account
aws ec2 create-vpc-peering-connection –vpc-id vpc-requester-id –peer-vpc-id vpc-accespter-id –peer-owner-id account-id –peer-region us-west-2
To create a VPC peering connection with a VPC in a different region
aws ec2 create-vpc-peering-connection –vpc-id vpc-requester-id –peer-vpc-id vpc-accespter-id –peer-region us-east-1