Volume 2 · Chapter 5 — AWS Networking Deep Dive (VPC)
Connecting Networks: Peering, Transit Gateway, VPN and Direct Connect
5.1 Introduction
Real enterprises never have just one isolated VPC. They have many VPCs across teams and environments, plus on-premises data centres and branch offices that must all connect to AWS and to each other. This chapter covers the tools for connecting networks: VPC peering for one-to-one links, Transit Gateway for connecting many networks at scale, and Site-to-Site VPN and Direct Connect for joining on-premises to AWS. Choosing among them is a common architecture and interview question, because each trades off simplicity, scale, performance, and cost differently.
5.2 VPC Peering
VPC peering creates a direct, private one-to-one connection between two VPCs so resources in each can communicate using private IPs as if on the same network. It’s simple and has no bandwidth bottleneck, but it has a critical limitation: peering is not transitive. If VPC A peers with B and B peers with C, A cannot reach C through B - you’d need a direct A-to-C peering as well. This means connecting many VPCs with peering requires a full mesh of connections that grows unmanageably (n VPCs need roughly n-squared peerings), which is why peering suits a small number of VPCs that need direct links but doesn’t scale to a large estate. The two VPCs also can’t have overlapping CIDR ranges.
5.3 Transit Gateway
Transit Gateway solves the scaling problem by acting as a central hub that many VPCs and on-premises connections attach to, so any attached network can reach any other through the hub instead of via a mesh of direct links. Instead of managing n-squared peerings, each VPC connects once to the Transit Gateway, and routing between them is handled centrally. This hub-and-spoke model is how enterprises connect dozens or hundreds of VPCs and their data centres cleanly, with centralized routing control and the ability to segment which networks can talk to which. For a large bank with many VPCs across business units and environments, Transit Gateway is the backbone that ties them together.
flowchart TB
subgraph Mesh["VPC Peering - full mesh (doesn't scale)"]
A1[VPC A] --- B1[VPC B]
B1 --- C1[VPC C]
A1 --- C1
end
subgraph Hub["Transit Gateway - hub & spoke (scales)"]
TGW((Transit Gateway))
A2[VPC A] --- TGW
B2[VPC B] --- TGW
C2[VPC C] --- TGW
DC[On-prem data centre] --- TGW
end 5.4 Site-to-Site VPN vs Direct Connect
To join an on-premises network to AWS there are two options with a clear trade-off. A Site-to-Site VPN creates an encrypted tunnel between the corporate network and AWS over the public internet - it’s quick to set up and inexpensive, but because it rides the public internet, its latency and throughput vary with internet conditions. Direct Connect provides a dedicated, private physical connection between the corporate data centre and AWS - it delivers consistent low latency, higher and more predictable bandwidth, and traffic that never touches the public internet, at the cost of more time and money to provision. Banks typically choose Direct Connect for connecting branches and core systems because they need reliable, private, high-performance connectivity, and they often run a Site-to-Site VPN as an encrypted backup path in case the Direct Connect link fails.
5.5 Choosing the Right Option
The decision framework is straightforward. To connect a small number of VPCs that need direct private links, use VPC peering. To connect many VPCs and on-premises networks at scale with central routing, use Transit Gateway. To connect on-premises to AWS quickly and cheaply, or as a backup, use Site-to-Site VPN. To connect on-premises to AWS with consistent, private, high performance for production-critical traffic, use Direct Connect - often with a VPN as failover. These aren’t mutually exclusive: a real enterprise architecture commonly uses Transit Gateway as the hub, Direct Connect (backed by VPN) for the on-premises link into that hub, and PrivateLink for sharing individual services - each tool for the job it fits.
5.6 Banking Production Scenario
A bank runs many VPCs - separate ones for payments, lending, and shared services, across production and non-production - and connects them all to a central Transit Gateway rather than a tangle of peerings, with routing segmented so non-production can’t reach production. Its data centres and branches connect into the same Transit Gateway over Direct Connect for consistent, private, low-latency access, with a Site-to-Site VPN configured as automatic encrypted failover should the Direct Connect circuit go down. Where it needs to share a single service with a fintech partner, it uses PrivateLink rather than opening broad connectivity. The whole estate is tied together through the hub, giving central control, clean scaling, and private high-performance links to on-premises.
5.7 Troubleshooting: Cross-Network Connectivity
Cross-network connectivity problems have recognizable causes. If two peered VPCs can’t communicate, the usual issues are missing route-table entries pointing at the peering connection, overlapping CIDR ranges (which make peering impossible), or security group/NACL rules blocking the traffic. If a resource can reach one VPC but not another “behind” it, that’s the non-transitive nature of peering - the fix is Transit Gateway or a direct peering. For Transit Gateway, connectivity gaps usually come from the route tables on the gateway or the attached VPCs not being configured to route to each other. For VPN or Direct Connect, on-premises reachability failures often trace to routing configuration on either side or overlapping address ranges. The consistent diagnostic is to verify routes on both ends point to the right connection, confirm no CIDR overlap, and check the firewall layers - the same route-then-rules discipline as within a single VPC.
Compare VPC peering and Transit Gateway. When would you use each?
VPC peering and Transit Gateway both connect VPCs privately, but they scale very differently, and the choice comes down to how many networks you’re connecting. VPC peering creates a direct one-to-one private connection between two VPCs so their resources communicate over private IPs as if on the same network. It’s simple and has no bandwidth bottleneck, which makes it good for connecting a small number of VPCs that need direct links. Its defining limitation is that peering is not transitive: if A peers with B and B peers with C, A cannot reach C through B - you’d need a separate A-to-C peering. So connecting many VPCs with peering requires a full mesh where every pair is directly peered, and the number of connections grows roughly with the square of the number of VPCs, which quickly becomes unmanageable. Peering also can’t connect VPCs with overlapping CIDR ranges. Transit Gateway solves exactly this scaling problem by acting as a central hub that many VPCs - and on-premises connections - attach to, so any attached network can reach any other through the hub rather than via direct links between every pair. Each VPC connects once to the Transit Gateway instead of to every other VPC, routing is managed centrally, and you can segment which networks are allowed to communicate. This hub-and-spoke model is how enterprises connect dozens or hundreds of VPCs and their data centres cleanly. So the decision is: use VPC peering when you have a small number of VPCs that need direct private connections and the simplicity is worth it; use Transit Gateway when you’re connecting many VPCs and on-premises networks at scale and need central routing, segmentation, and manageability without a mesh. A large bank with separate VPCs per business unit and environment, plus data centres to connect, uses Transit Gateway as the backbone precisely because peering would explode into an unmanageable mesh and couldn’t provide central control. The key concepts to land are peering’s non-transitivity and mesh growth versus Transit Gateway’s transitive, centrally-routed hub - that’s what determines which one fits.
How would you connect a bank's on-premises data centre and branches to AWS, and why?
I’d connect them primarily with Direct Connect for consistent private performance, backed by a Site-to-Site VPN for failover, and route them into a Transit Gateway hub so they reach the bank’s VPCs cleanly. The two fundamental options for joining on-premises to AWS are a Site-to-Site VPN and Direct Connect, and they trade off differently. A Site-to-Site VPN creates an encrypted tunnel over the public internet - quick to set up and inexpensive, but because it rides the public internet its latency and throughput vary with internet conditions, so it’s less predictable. Direct Connect provides a dedicated private physical connection between the data centre and AWS, giving consistent low latency, higher and more predictable bandwidth, and traffic that never touches the public internet - at the cost of more time and money to provision. For a bank connecting its core systems and branches, reliability, predictable performance, and privacy are paramount, so Direct Connect is the right primary choice: branches and the data centre get stable, private, high-performance access to AWS, and sensitive traffic stays off the public internet. But a single link is a single point of failure, so I run a Site-to-Site VPN as an automatic encrypted backup path - if the Direct Connect circuit goes down, connectivity fails over to the VPN, trading some performance for continuity rather than losing the connection entirely. On the AWS side, rather than connecting the on-premises link to one VPC, I terminate it into a Transit Gateway, which the bank’s many VPCs also attach to - so the data centre and branches can reach any of the bank’s VPCs through the central hub, with routing controlled and segmented centrally (for example, keeping non-production separate from production). This combination gives the bank the private, consistent, high-performance connectivity its regulated workloads need, resilience through VPN failover, and clean, scalable reach into a multi-VPC estate through the Transit Gateway hub. So the reasoning is: Direct Connect for predictable private performance, VPN for resilient failover, and Transit Gateway to tie the on-premises networks into the whole AWS estate - each chosen because banks prioritize reliability, privacy, and manageable scale.
Chapter Revision Notes
- VPC peering: direct one-to-one private link between two VPCs; simple but non-transitive and mesh-growth, so it doesn’t scale; no CIDR overlap.
- Transit Gateway: central hub connecting many VPCs and on-premises networks with central, segmentable routing - the enterprise backbone.
- Site-to-Site VPN: encrypted tunnel over the internet - quick, cheap, variable performance; good as backup.
- Direct Connect: dedicated private link - consistent low latency, private, higher bandwidth; banks’ primary on-premises link, often with VPN failover.
- Real architectures combine them: Transit Gateway hub + Direct Connect (VPN backup) for on-prem + PrivateLink for single services.