VPC Peering, Transit Gateway and Hybrid Connectivity
Connect VPCs to each other and to on-premises networks using peering, Transit Gateway, Site-to-Site VPN and Direct Connect.
Advanced · about 4 hours · difficulty 4/5
Learn first: NAT Gateways, Security Groups and NACLs
As soon as a company has more than one VPC or an office network, you need to connect them. Each option trades simplicity, scale and cost.
VPC peering
- A private, one-to-one connection between two VPCs (same or different accounts and regions).
- Not transitive: if A peers with B and B with C, A cannot reach C through B.
- No overlapping CIDRs allowed. Cheap and simple for a handful of VPCs.
Transit Gateway
- A regional hub that many VPCs and VPNs attach to, like a cloud router.
- Supports route tables for segmentation (prod cannot talk to dev).
- Scales to thousands of attachments, but charges per attachment hour and per GB.
- Azure's equivalent is a hub VNet or Virtual WAN; GCP uses Network Connectivity Center.
Hybrid connectivity
- Site-to-Site VPN: encrypted IPsec tunnels over the internet to an office or data centre. Quick to set up.
- Direct Connect: a dedicated private link from a data centre or partner location (there are locations in Mumbai, Chennai, Delhi and other cities). Predictable latency, higher cost and lead time.
- Client VPN for individual users.
Choosing
- Two or three VPCs: peering.
- Many VPCs or accounts, plus on-premises: Transit Gateway.
- Exposing one service to many consumers without full network access: PrivateLink (next topic).
Pitfalls
- Overlapping CIDRs that make peering impossible later.
- Building a mesh of dozens of peering connections instead of a hub.
You are ready to move on when you can choose between peering, Transit Gateway and PrivateLink for a given scenario and explain why.
Key concepts
- VPC peering
- Non-transitive routing
- Transit Gateway
- Transit Gateway route tables
- Site-to-Site VPN
- Direct Connect
- Client VPN
Mini project
Create two small VPCs with non-overlapping CIDRs, peer them, update route tables and security groups, and ping between two free-tier instances. Write how the design would change with ten VPCs. Skip Transit Gateway in the lab because it bills hourly; terminate instances and delete the peering when done.
Check yourself
VPC A peers with B, and B peers with C. Can an instance in A reach C? What would you use instead?
Free resources
- VPC peering (AWS)
- AWS Transit Gateway (AWS)
- AWS Direct Connect (AWS)