VPC peering
VPC peering for private connections between two VPCs, the no-overlap and no-transitivity rules, route tables, cross-account and cross-Region peering, and referencing security groups.
What it is
VPC peering privately connects two VPCs using AWS's network.
- Makes them behave as if they were in the same network.
- They must not have overlapping CIDRs.
- A VPC peering connection is NOT transitive: it must be established for each pair of VPCs that need to communicate.
- The route tables in each VPC's subnets must be updated so EC2 instances can communicate (route the peer's CIDR to the peering connection
pcx-…).
Good to know
- A VPC peering connection can be created between VPCs in different AWS accounts and Regions (inter-Region traffic is encrypted and stays on the AWS backbone).
- Rules can reference a security group in a peered VPC as a source or destination (it works cross-account, but only in the same Region): for example, source
123456789012/sg-027ad1f7865d4be76. - For a peered VPC in a different Region, use its CIDR in security group rules instead.
- No bandwidth bottleneck or single point of failure: peering isn't a gateway.
Real-world examples
- A shared-services VPC (Active Directory, monitoring) is peered with three application VPCs. The application VPCs can't talk to each other through it, which is exactly what the security team wants.
Exam tips
- "Connect two VPCs privately" → VPC peering (with route table updates).
- "VPC A peered with B and C; B can't reach C" → peering isn't transitive; peer B and C, or use Transit Gateway.
- "Peering fails to create" → overlapping CIDRs.
- "Many VPCs (dozens or more)" → Transit Gateway instead of a mesh of peerings.
Common traps
- "Peering works without route changes." Both sides need routes.
- "Reference a security group from a peered VPC in another Region." Same Region only; use CIDRs across Regions.
Check yourself
Peering two VPCs is free (cross-AZ or cross-Region data is billed), but needs instances to test, so instead:
No: their CIDRs overlap. One VPC must be re-addressed (or the service exposed with PrivateLink, which tolerates overlapping CIDRs).
AWS documentation
AWS Network Firewall
The network protection options on AWS, and AWS Network Firewall for layer 3 to layer 7 protection of a whole VPC with stateful rules, domain filtering and intrusion prevention.
VPC endpoints and PrivateLink
VPC endpoints for private access to AWS services, interface endpoints (PrivateLink) vs gateway endpoints, choosing for S3, Lambda in a VPC reaching DynamoDB, and PrivateLink endpoint services.