VPC Peering and Transit
Joining VPCs — pairwise or through a hub
Peering joins two VPCs; Transit Gateway or a hub VNet joins many. Direct peering is fast and cheap but non-transitive; hubs add inspection and centralization at the cost of design complexity.
What you will learn
- Explain peer relationships and transitivity
- Design hub-and-spoke with Transit Gateway or shared services
- Choose mesh vs hub based on size and inspection needs
VPC peering connects two VPCs directly (no gateway). It's non-transitive: A↔B plus B↔C does NOT give A→C. Transit Gateway / VNet hub / GCP shared VPC centralize connections so many networks talk through one managed hub.
What is this?
VPC peering establishes network connectivity between two VPCs (or across accounts) so they can use each other's CIDRs directly with high bandwidth and low cost — routes must be added to each table, CIDRs cannot overlap, and peering is non-transitive. Transit Gateway (AWS) is a managed star hub that attaches VPCs, VPNs and DX and does transitive routing between attachments with optional inter-region peering. Azure uses VNet peering (also non-transitive) plus a hub VNet with NVAs; GCP keeps one global VPC (or uses Shared VPC) and peering for cross-project.
Why do you need it?
- Peering is the cheapest way to connect two VPCs for shared services.
- Hub-and-spoke collapses O(N²) peers into O(N) attachments.
- A hub is where inspection lives: single NVAs, firewalls, route domains.
- These architectures are the backbone of every multi-account landing zone.
Mental model
Two offices with a private walkway vs a central transit hub
Peering vs transit
A walkway (peering) connects two buildings directly. A transit hub (Transit Gateway) is the airport: many airlines (VPCs) share one terminal, routing passengers through central security (inspection).
How it works
- Create a peering connection, accept it (optionally across accounts), then add routes on both sides.
- Non-transitive: each peer must itself be peered; routing never hops through a third party.
- Transit Gateway: attach VPCs via attachments; create routes on the TGW route table; transitive between attachments.
- Inter-region TGW peering connects regions; DX/VPN attach on-prem.
- GCP Shared VPC centralizes subnets; Azure hub VNet + peer spokes work similarly.
Mesh (peering) vs hub (transit).
In production
- A dev account peers to the prod account's shared-services VPC to use the bastion and monitoring stack.
- A landing zone uses a Transit Gateway hub with per-OU route tables and a centralized firewall attachment.
- GCP uses Shared VPC for the platform team plus peering for third-party SaaS integrations.
Best practices
- Prefer hub-and-spoke when N VPCs > ~5 or when you need central inspection.
- Use non-overlapping CIDRs and document the allocation before peering.
- Enable data-protection/inspection carefully; private peering traffic is encrypted where supported.
- Route only what's needed; avoid black-hole routes from sloppy transitive propagation.
Common mistakes
- Assuming peering is transitive and routing A→C through B.
- Peering VPCs with overlapping CIDRs — cloud providers often reject, or routes silently fail.
- Hub VPC becoming a network bottleneck via forced inspection for everything.
- No route-table isolation: every VPC sees every other route and budgets/audits blur.
Common issues
Peer shows in pending accept for hoursThe other side never accepted, or IAM crossed accounts
Accept from the peer account; verify cross-account permissions if using org.
Traffic works one direction onlyMissing route in one VPC's table
Add the reverse route (peer CIDR → peering) on the silent side.
TGW attachment doesn't routeTGW route table lacks the destination or association
Propagate the attachment's VPC route and ensure an explicit route exists in the TGW table.
Debugging tips
- Verify both directions of the peer: connection status, then both route tables.
- Reachability analyzer across the peering connection catches route/SG/gateway gaps.
- For TGW: check attachment state and route tables (static vs propagated).
- Watch for asymmetric paths where one side routes via the TGW and the other via peering.
Interview checkpoint
Hands-on lab
- Create two VPCs with non-overlapping CIDRs
- Create and accept a peering connection
- Verify routes and connectivity
Peer Two VPCs and Verify Routes
30 min · intermediate
Quick quiz
Which is TRUE about VPC peering transitivity?
A Transit Gateway lets you attach many VPCs and route transitively between them.