Sub topic 3
Why VPC peering stops scaling
This chapter assumes you know CIDR blocks, subnets, route tables, and security groups. It explains where VPC peering works well and where it breaks down, which is the reason Transit Gateway exists.
What peering gives you
A VPC peering connection is a one-to-one link between two VPCs. Traffic between them stays on the AWS network and uses private IP addresses. There is no gateway or appliance to size, and no hourly charge for the connection itself. For two or three VPCs it is the simplest option.
Peering has two requirements. The VPCs must not have overlapping CIDR blocks, and each side needs a route to the other side's CIDR.
aws ec2 create-vpc-peering-connection \
--vpc-id vpc-0aaa1111bbb22222c \
--peer-vpc-id vpc-0ddd3333eee44444f
aws ec2 accept-vpc-peering-connection \
--vpc-peering-connection-id pcx-0123456789abcdef0
aws ec2 create-route \
--route-table-id rtb-0123456789abcdef0 \
--destination-cidr-block 10.1.0.0/16 \
--vpc-peering-connection-id pcx-0123456789abcdef0You must also add the matching route in the peer VPC's route table. Peering does not add routes for you.
Peering is non-transitive
Peering is non-transitive. If VPC A is peered with B, and B is peered with C, then A cannot reach C through B. AWS drops the traffic. Edge-to-edge routing through a peer, such as using B's internet gateway, VPN, or NAT gateway, is also not supported.
To connect A and C, you must create a third peering connection between them.
The full-mesh problem
Because of this rule, connecting every VPC to every other VPC needs a full mesh. The number of connections for n VPCs is n × (n − 1) / 2.
| VPCs | Peering connections | Route table updates (one per direction, per VPC pair) |
|---|---|---|
| 3 | 3 | 6 |
| 10 | 45 | 90 |
| 25 | 300 | 600 |
| 50 | 1,225 | 2,450 |
The growth is quadratic. Every new VPC needs a new connection and a route to every existing VPC. The operational costs include:
- Each connection must be requested, accepted, and routed on both sides.
- Route tables fill up. Each VPC route table has a quota on routes, and a VPC has a quota on active peering connections (50 by default, adjustable to 125). Check the current values in Service Quotas.
- Changing a CIDR block means updating routes in every peer.
- Auditing who can reach whom means reading many separate connections.
Other limits
- Peering cannot be used with overlapping CIDR blocks.
- Security group rules can reference a peer's security group, but you must manage them per connection.
- Peering does not provide a central place to apply routing policy or to insert inspection.
When peering is still the right choice
Peering is a good fit for a small, stable set of VPCs, or for a high-bandwidth link between two VPCs. It has no per-GB processing charge at the gateway, though inter-AZ and inter-Region data transfer charges still apply. The next chapter introduces Transit Gateway, which replaces the mesh with a single hub.
Exercise
You have 12 VPCs that must all reach each other using peering. How many peering connections do you need, and why can't you peer each VPC only with one central VPC?
Show answer
You need 12 × 11 / 2 = 66 connections. A central VPC would not work because peering is non-transitive: two spoke VPCs peered only to the central VPC cannot send traffic to each other through it.