Purpose
This article gives the steps to setup Amazon Web Services Virtual Private Cloud Peering. This can be good for the need to give another VPC access to EFS, RDS etc. during a migration.
Prerequisites
- Must have different CIDR Blocks that do not conflict.
Create Connection
- Login to the AWS Web Console
- Select VPC | Peering Connections
- Select Create VPC Peering Connection
- Add Name Tag
- Select the two VPC to connect
- Select VPC | Peering Connections
Accept Pending
After creating the connection it will remain in a pending acceptance state until you accept it or it times out (30 days).
Show Current State
1 |
aws ec2 --profile account1 describe-vpc-peering-connections |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
{ "VpcPeeringConnections": [ { "Status": { "Message": "Pending Acceptance by 1234567890", "Code": "pending-acceptance" }, "Tags": [ { "Value": "your-peering-name-tag", "Key": "Name" } ], "RequesterVpcInfo": { "PeeringOptions": { "AllowEgressFromLocalVpcToRemoteClassicLink": false, "AllowDnsResolutionFromRemoteVpc": false, "AllowEgressFromLocalClassicLinkToRemoteVpc": false }, "OwnerId": "1234567890", "VpcId": "vpc-00000001", "CidrBlock": "10.100.0.0/16" }, "VpcPeeringConnectionId": "pcx-abcde123", "ExpirationTime": "2016-12-04T23:35:08.000Z", "AccepterVpcInfo": { "OwnerId": "1234567890", "VpcId": "vpc-00000002" } } ] } |
Accept from CLI
1 |
aws ec2 --profile account1 accept-vpc-peering-connection --vpc-peering-connection-id pcx-abcde123 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
{ "VpcPeeringConnection": { "Status": { "Message": "Provisioning", "Code": "provisioning" }, "Tags": [], "AccepterVpcInfo": { "PeeringOptions": { "AllowEgressFromLocalVpcToRemoteClassicLink": false, "AllowDnsResolutionFromRemoteVpc": false, "AllowEgressFromLocalClassicLinkToRemoteVpc": false }, "OwnerId": "1234567890", "VpcId": "vpc-00000001", "CidrBlock": "10.100.0.0/16" }, "VpcPeeringConnectionId": "pcx-abcde123", "RequesterVpcInfo": { "PeeringOptions": { "AllowEgressFromLocalVpcToRemoteClassicLink": false, "AllowDnsResolutionFromRemoteVpc": false, "AllowEgressFromLocalClassicLinkToRemoteVpc": false }, "OwnerId": "1234567890", "VpcId": "vpc-00000002", "CidrBlock": "10.120.0.0/16" } } } |
1 |
aws ec2 --profile account1 describe-vpc-peering-connections |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
{ "VpcPeeringConnections": [ { "Status": { "Message": "Active", "Code": "active" }, "Tags": [ { "Value": "your-peering-name-tag", "Key": "Name" } ], "AccepterVpcInfo": { "PeeringOptions": { "AllowEgressFromLocalVpcToRemoteClassicLink": false, "AllowDnsResolutionFromRemoteVpc": false, "AllowEgressFromLocalClassicLinkToRemoteVpc": false }, "OwnerId": "1234567890", "VpcId": "vpc-00000001", "CidrBlock": "10.100.0.0/16" }, "VpcPeeringConnectionId": "pcx-abcde123", "RequesterVpcInfo": { "PeeringOptions": { "AllowEgressFromLocalVpcToRemoteClassicLink": false, "AllowDnsResolutionFromRemoteVpc": false, "AllowEgressFromLocalClassicLinkToRemoteVpc": false }, "OwnerId": "1234567890", "VpcId": "vpc-00000002", "CidrBlock": "10.120.0.0/16" } } ] } |