What is AWS Transit Gateway, and why use it instead of VPC peering when connecting many VPCs and on-premises networks?
Answer
AWS Transit Gateway is a Regional network hub that connects many VPCs, VPNs and Direct Connect links through a single gateway, using route tables you control. It replaces a mesh of point-to-point VPC peering connections with a hub-and-spoke design, and unlike peering it supports transitive routing, so every attached network can reach the others if the routes allow it.
The problem it solves
VPC peering is one-to-one and non-transitive: if A peers with B and B peers with C, A still cannot reach C. Connecting n VPCs in a full mesh needs n(n-1)/2 peerings, so 20 VPCs means 190 peering connections, each with its own route table entries. Add on-prem VPNs to every VPC and it becomes unmanageable.
With Transit Gateway, each VPC and each on-prem link attaches once to the hub.
Building blocks
Attachments: VPC, Site-to-Site VPN, Direct Connect gateway, Transit Gateway peering (to a TGW in another Region or account), and Connect attachments for SD-WAN appliances using GRE and BGP.
Transit Gateway route tables: decide where traffic from an attachment can go.
Association: each attachment is associated with exactly one TGW route table, which is used to route traffic coming from it.
Propagation: attachments can propagate their routes into one or more route tables automatically. VPN and Direct Connect routes come in via BGP.
Sharing: a TGW in a central networking account is shared to other accounts with AWS Resource Access Manager (RAM).
Segmentation with route tables
A common enterprise pattern uses separate TGW route tables:
Prod table: prod VPCs plus shared services and on-prem.
Non-prod table: dev and staging VPCs plus shared services, but no route to prod.
Shared services table: reachable by everyone (DNS, CI runners, logging).
Inspection VPC: all east-west or egress traffic routed through AWS Network Firewall or third-party appliances, with appliance mode enabled so return traffic stays symmetric.
This gives a fintech, for example, a clean way to prove that a developer's sandbox VPC can never reach the payments VPC.
Transit Gateway vs VPC peering
VPC peering
Transit Gateway
Topology
Point to point
Hub and spoke
Transitive routing
No
Yes
On-prem VPN and Direct Connect
Per VPC
Attach once, shared
Cost
No hourly charge, only data transfer
Per attachment-hour plus per GB processed
Latency
Lowest (direct path)
One extra hop
Best for
A few VPCs, high-volume pairs
Tens to thousands of VPCs
Gotchas
Transit Gateway is Regional. Cross-Region connectivity uses TGW peering, which needs static routes.
Overlapping CIDR blocks still break routing. Plan IP ranges across accounts before you need them.
You must update both the VPC subnet route tables (point to the TGW) and the TGW route tables; missing either is the most common cause of "it does not ping".
The per-GB processing charge can make chatty high-volume VPC pairs cheaper with a direct peering connection alongside the TGW.
For global, policy-driven networks, AWS Cloud WAN builds on top of Transit Gateway concepts.
Transit Gateway hub and spoke. Every network attaches once, and route tables decide who can talk to whom.
On-premises data center: Connected via VPN or Direct Connect gateway.
Transit Gateway attachments: One attachment per VPC, VPN or DX gateway.
Transit Gateway route tables: Association and propagation control reachability.
Prod, non-prod, shared VPCs: Segmented by separate route tables.
Inspection VPC: Optional firewall for east-west and egress traffic.
Code examples
Create a TGW and attach a VPC
# Hub in the networking account
aws ec2 create-transit-gateway --description "core-hub" \
--options DefaultRouteTableAssociation=disable,DefaultRouteTablePropagation=disable
# Attach a VPC using one subnet per Availability Zone
aws ec2 create-transit-gateway-vpc-attachment \
--transit-gateway-id tgw-0abc123 --vpc-id vpc-0prod \
--subnet-ids subnet-az1 subnet-az2
# In the VPC's subnet route table, send on-prem traffic to the TGW
aws ec2 create-route --route-table-id rtb-0prod \
--destination-cidr-block 10.100.0.0/16 --transit-gateway-id tgw-0abc123
Disabling the default association and propagation forces you to place each attachment into a deliberate route table, which is how segmentation is enforced.
Key points
Transit Gateway is a Regional hub that supports transitive routing.
Attachments: VPC, VPN, Direct Connect gateway, TGW peering and Connect.
Each attachment associates with one route table and can propagate into many.
Charged per attachment-hour and per GB processed, unlike VPC peering.
Update both VPC route tables and TGW route tables for traffic to flow.
Common follow-up questions
How would you isolate production VPCs from development VPCs on one Transit Gateway?
How do you connect Transit Gateways in two Regions?
When is VPC peering still a better choice than Transit Gateway?
How would you route all egress traffic through a central firewall?
Interview tips
Start with the non-transitive peering problem and the n(n-1)/2 math; it makes the motivation obvious.
Explain association versus propagation clearly, since that is where most candidates get vague.
Mention the cost trade-off and segmentation with multiple route tables to sound like you have designed one.