Asterrr's Handbook

Connecting VPCs

Peering, Transit Gateway, PrivateLink, VPC Lattice, VPC sharing and Cloud WAN, and how to choose between them.

Exam tasks: 1.1 (evaluate connectivity options for multiple VPCs, use service endpoints), 2.3

The decision: do the VPCs need to reach each other's whole network, or just one service? And how many VPCs are involved?

Choosing an option

Side by side

VPC peeringTransit GatewayPrivateLinkVPC Lattice
Shape1:1 linkRegional hub and spokeOne-way: consumer → serviceApplication-layer service network
Transitive routingNoYes, controlled by TGW route tablesN/A (no routing)N/A (no routing)
Overlapping CIDRsNot allowedNot allowed (without NAT)FineFine
Scales toFull mesh gets unmanageable: 20 VPCs = 190 linksThousands of attachmentsThousands of consumer VPCsMany services and VPCs
Hybrid (VPN or DX)Can't use the peer's linksShared by all attachmentsConsumers on-premises can reach the endpoint—
CostNo hourly fee. Data transfer onlyPer attachment-hour + per GB processedPer endpoint-hour + per GBPer service-hour + per GB and requests
Cross-accountYesShare the TGW with RAMYes, via allowlisted principalsShare the service network with RAM
n(n−1)/2
Peering links needed for a full mesh. 10 VPCs need 45; 50 VPCs need 1,225.
1.25 Gbps
Per VPN tunnel. Scale out with Transit Gateway ECMP across several tunnels.
Regional
A Transit Gateway lives in one Region. Link Regions with TGW peering.

VPC peering

Peering is the cheapest option and the one with the fewest parts, but its routing is deliberately limited:

  • No transitive routing. If A is peered with B and B with C, A still can't reach C through B.
  • No edge-to-edge routing. A VPC can't use its peer's internet gateway, NAT gateway, VPN, Direct Connect or gateway endpoint.
  • No overlapping CIDRs between the two VPCs.

Peering as a hub

An answer that sends traffic through a central VPC over peering, to reach on-premises, the internet or a third VPC, doesn't work. You need a Transit Gateway or an appliance in that central VPC.

Which peer wins? Longest prefix match

A VPC can peer with two VPCs whose CIDRs overlap each other. Its route table then decides where each packet goes, and the most specific matching route always wins.

Destination from the hubMatching routesGoes to
172.20.8.15/16 → pcx-a, /24 → pcx-bSpoke B. The /24 is more specific
172.20.3.40/16 → pcx-aSpoke A
172.20.8.99 in Spoke A/24 → pcx-bSpoke B. Spoke A's 172.20.8.0/24 is unreachable from the hub

The last row is what the exam tests: overlapping peers work only if you accept that part of one VPC can't be reached.

Exam signal

If a question mentions overlapping CIDRs, network-level options (peering, Transit Gateway) are out unless NAT is involved. Look for PrivateLink or VPC Lattice, which connect services rather than networks.

Transit Gateway

A regional router that VPCs, VPNs, Direct Connect gateways and other Transit Gateways attach to.

  • Segmentation through route tables. For example, put prod and dev attachments in separate route tables that can both reach a shared-services route table but not each other.
  • Centralized egress and inspection. Send spokes to one inspection VPC with a NAT gateway or firewall. Turn on appliance mode on that attachment so return traffic uses the same AZ and stateful firewalls don't drop it.
  • Hybrid in one place. Terminate a single Direct Connect (transit VIF via a DX gateway) or VPN on the TGW, and every attached VPC can use it.
  • Multi-account. The network account owns the TGW and shares it with the organization through AWS RAM.

Cost blind spot

Transit Gateway charges for every GB it processes. For two VPCs that exchange a lot of data, peering can be much cheaper. You can use both: peering for the heavy pair, and the TGW for everything else.

The provider puts a service behind a Network Load Balancer and publishes it as an endpoint service. Consumers create an interface endpoint in their own VPC, which appears as an ENI with a private IP address.

  • Only the consumer can open connections. The provider can't reach into the consumer's network.
  • CIDRs don't matter, so it works for thousands of customer VPCs that all use 10.0.0.0/16.
  • Providers control access by allowlisting AWS principals and can require manual approval of each connection.

This is the standard pattern for a SaaS provider serving many customers.

VPC sharing

The owner account shares subnets with other accounts in the organization through AWS RAM. Participant accounts launch resources directly into those subnets. There's no peering and no attachment: everything is in one VPC.

Use it when a central network team wants to own the IP plan, routing and egress, while app teams keep separate accounts for billing and permissions. Participants can't change the VPC's route tables, NACLs or gateways.

Cloud WAN

A managed global network, defined in one policy document. Segments such as prod, dev and partner behave like isolated routing domains across every Region. Choose it over hand-built TGW peering when a question stresses many Regions, central policy, or SD-WAN and branch integration.

Scenarios

Scenario
A company runs 60 VPCs across 12 accounts in one Region. All of them need to reach an on-premises data center over the company's existing Direct Connect connection, and prod VPCs must not be able to reach dev VPCs. Which design has the LEAST operational overhead?
Scenario
A SaaS company wants to offer its API privately to hundreds of customers' VPCs. Many customers use the same CIDR ranges as the SaaS VPC. Traffic must not traverse the internet. What should the company do?
Scenario
VPC A (10.1.0.0/16) is peered with VPC B, and VPC B is peered with VPC C. An engineer adds a route in VPC A for VPC C's CIDR with VPC B's peering connection as the target. What happens to traffic from A to C?

Further reading

On this page