VPC Peering & Transit Gateway
Key concepts
VPC peering limitations
Transit Gateway for hub-and-spoke
Transit Gateway route tables
Peering vs Transit Gateway decision
Inter-region peering
Overview
A VPC (Virtual Private Cloud) is an isolated network in AWS, and real architectures usually need many of them to talk to each other privately. VPC peering is a one-to-one private connection between two VPCs using AWS backbone networking. AWS Transit Gateway (TGW) is a regional network hub that connects many VPCs, VPN connections, and on-premises networks through a single attachment point, replacing a tangle of individual peering links with a hub-and-spoke topology.
This topic is high-yield on the SAA-C03 exam through "how should these networks connect" scenarios. You should know why VPC peering does not scale (it is non-transitive and grows quadratically), how Transit Gateway provides transitive routing, how Transit Gateway route tables segment traffic, when to pick peering over Transit Gateway, and how both options work across AWS Regions.
Peering for a Few VPCs, Transit Gateway for Many
Use VPC peering for a small number of VPCs that each need a direct, low-cost path to one another. Move to Transit Gateway once you connect many VPCs, hybrid networks, or need a central place to apply routing and segmentation, because peering connections do not pass traffic transitively.
Remember three peering rules: peering is non-transitive (A to B and B to C does not give A to C), CIDR ranges cannot overlap, and edge-to-edge routing is not allowed (you cannot route through a peer to reach its VPN or internet gateway). Transit Gateway solves transitivity, scales to thousands of attachments, and uses route tables to control which attachments can reach each other.
Key Concepts
VPC Peering Limitations
Why Peering Does Not Scale
A VPC peering connection links exactly two VPCs and uses AWS internal networking, so there is no bandwidth bottleneck or single point of failure and no per-hour charge for the connection itself. The constraints matter for the exam. Peering is non-transitive: if VPC A peers with B and B peers with C, A still cannot reach C through B. The CIDR (Classless Inter-Domain Routing) blocks of peered VPCs cannot overlap. Edge-to-edge routing is blocked, so you cannot use a peer to reach the other side internet gateway, NAT gateway, VPN, or Direct Connect. Because each pair needs its own connection, a full mesh of N VPCs requires N times (N minus 1) divided by 2 connections, which becomes unmanageable quickly.
VPC Peering Rules and Limits
| Property | Behavior |
|---|---|
| Connection scope | Exactly two VPCs per connection |
| Transitive routing | Not supported |
| Overlapping CIDRs | Not allowed |
| Edge-to-edge routing | Not allowed (no transit to peer IGW, NAT, VPN, Direct Connect) |
| Cross-Region | Supported (inter-Region peering) |
| Bandwidth | No aggregate limit imposed by peering |
| Connection cost | No hourly charge; pay only for data transfer |
Transit Gateway for Hub-and-Spoke
A Central Network Hub
Transit Gateway is a regional, highly available router that VPCs and on-premises connections attach to. Each VPC, VPN, or Direct Connect gateway connects once to the TGW (an attachment), and the TGW forwards traffic between them. This is transitive: any attachment can reach any other attachment that routing allows, so connecting N VPCs needs N attachments instead of a quadratic mesh. A single TGW supports thousands of attachments (the default limit is 5,000 per Transit Gateway), which makes it the standard pattern for large multi-VPC and hybrid networks. Each VPC attachment supports up to 100 Gbps of bandwidth per Availability Zone in each direction.
Connection Count: Full Mesh Peering vs Transit Gateway
| Number of VPCs | Peering Connections (Full Mesh) | Transit Gateway Attachments |
|---|---|---|
| 3 | 3 | 3 |
| 5 | 10 | 5 |
| 10 | 45 | 10 |
| 20 | 190 | 20 |
Transit Gateway Route Tables
Segmenting Traffic With Route Tables
A Transit Gateway route table controls which attachments can send traffic to which destinations, giving you network segmentation inside one TGW. Each attachment is associated with one route table (which routes that attachment uses for outbound decisions) and can propagate its VPC CIDRs into one or more route tables (which destinations other attachments learn). By associating production and development attachments with separate route tables and propagating selectively, you can let both reach shared services while keeping them isolated from each other, without spinning up extra Transit Gateways.
Transit Gateway
├── Route table: PROD
│ ├── Associated: prod-vpc attachment
│ └── Propagated routes: shared-services CIDR (prod can reach shared)
│
├── Route table: DEV
│ ├── Associated: dev-vpc attachment
│ └── Propagated routes: shared-services CIDR (dev can reach shared)
│
└── Route table: SHARED
├── Associated: shared-services-vpc attachment
└── Propagated routes: prod CIDR + dev CIDR (shared reaches both)
Result: prod <-> shared and dev <-> shared, but prod and dev stay isolated.Peering vs Transit Gateway Decision
Choosing the Right Connectivity
Choose VPC peering when you connect a small, fixed number of VPCs that mostly need point-to-point paths, want the lowest cost (no hourly hub charge), and do not need transitive routing. Choose Transit Gateway when the number of VPCs grows, when you need transitive any-to-any routing, when you also connect VPN or Direct Connect, or when you need a central point to enforce segmentation and inspection. Transit Gateway adds a per-attachment hourly charge plus per-GB data processing, so peering can be cheaper for just a few VPCs.
VPC Peering vs Transit Gateway
| Dimension | VPC Peering | Transit Gateway |
|---|---|---|
| Topology | One-to-one mesh | Hub-and-spoke |
| Transitive routing | No | Yes |
| Scales to many VPCs | Poorly (quadratic growth) | Well (thousands of attachments) |
| Hybrid (VPN, Direct Connect) | Not via the peer | Native attachments |
| Central segmentation | No | Yes (route tables) |
| Cost model | Data transfer only | Per attachment-hour plus data processed |
| Best for | A few VPCs, lowest cost | Many VPCs, hybrid, segmentation |
Inter-Region Peering and Inter-Region TGW Peering
Connecting Across AWS Regions
Inter-Region VPC peering connects VPCs in different AWS Regions over the encrypted AWS global backbone, so cross-Region traffic stays off the public internet. The same rules apply: it is non-transitive, CIDRs cannot overlap, and some features (such as referencing a peer security group) are limited compared to same-Region peering. Transit Gateway is regional, so to span Regions you create a Transit Gateway peering attachment between a TGW in each Region. This connects two hubs and keeps the design scalable, while inter-Region VPC peering remains a simpler choice for a single cross-Region VPC pair.
Cross-Region Options
| Need | Use |
|---|---|
| One VPC in Region A talks to one VPC in Region B | Inter-Region VPC peering |
| Many VPCs across two Regions form one network | Transit Gateway peering attachment between two TGWs |
| Keep cross-Region traffic off the public internet | Either option (both use the AWS backbone) |
Best Practices
1. Start with peering only for a few stable VPCs
└── Switch to Transit Gateway before a full mesh becomes hard to manage
2. Plan non-overlapping CIDR blocks up front
└── Overlapping ranges block both peering and TGW attachments
3. Use Transit Gateway route tables to segment environments
├── Associate prod and dev with separate route tables
└── Propagate only shared-services routes into each
4. Attach VPN and Direct Connect to the Transit Gateway
└── Centralizes hybrid connectivity instead of per-VPC links
5. Cross Regions deliberately
├── Inter-Region VPC peering for a single cross-Region pair
└── Transit Gateway peering attachment for many VPCs across RegionsCommon Pitfalls
Pitfall 1: Expecting Transitive Routing From Peering
Mistake: Peering VPC A to B and B to C, then assuming A can reach C through B.
Why it fails: VPC peering is non-transitive, so traffic never flows through an intermediate peer.
Correct Approach: Add a direct A-to-C peering connection, or move all three VPCs onto a Transit Gateway, which routes transitively.
Pitfall 2: Overlapping CIDR Blocks
Mistake: Reusing the same CIDR range (for example 10.0.0.0/16) across VPCs that later need to connect.
Why it fails: Both VPC peering and Transit Gateway attachments reject overlapping CIDR ranges, because routing becomes ambiguous.
Correct Approach: Assign unique, non-overlapping CIDR blocks during VPC planning so any future connection is possible.
Pitfall 3: Building a Full Mesh of Peering Connections
Mistake: Connecting 10 or more VPCs with point-to-point peering, creating dozens of connections and route table entries.
Why it fails: A full mesh grows as N times (N minus 1) divided by 2, so it becomes operationally fragile and hard to audit.
Correct Approach: Use Transit Gateway as a hub so each VPC needs a single attachment and routing lives in one place.
Pitfall 4: Forgetting Route Tables and Security Groups
Mistake: Creating a peering connection or TGW attachment but never updating the VPC subnet route tables or security groups.
Why it fails: The connection exists, yet traffic has no route to the peer CIDR and security groups still block it, so the link appears broken.
Correct Approach: Add routes to the peer or Transit Gateway CIDR in each subnet route table and open the required ports in security groups and network ACLs.
Test Your Knowledge
A company has 12 VPCs that all need to communicate with each other and with an on-premises data center over VPN. They want one central place to manage routing. Which design fits best?
An architect peers VPC A with VPC B and VPC B with VPC C. Application servers in VPC A cannot reach databases in VPC C. What explains this?
A team runs production and development VPCs attached to one Transit Gateway. Both must reach a shared-services VPC, but production and development must stay isolated from each other. What achieves this?
Related Services
Quick Reference
Well-Known Limits and Defaults
Peering and Transit Gateway Quick Facts
| Item | Value |
|---|---|
| Attachments per Transit Gateway (default) | 5,000 |
| VPCs per peering connection | 2 |
| Transitive routing (peering) | Not supported |
| Transitive routing (Transit Gateway) | Supported |
| Overlapping CIDRs | Not allowed for either option |
| Cross-Region (peering) | Inter-Region VPC peering |
| Cross-Region (Transit Gateway) | Transit Gateway peering attachment |
| Bandwidth per VPC attachment | Up to 100 Gbps per Availability Zone each direction |
Common CLI Commands
# Create a VPC peering connection (same or cross-Region)
aws ec2 create-vpc-peering-connection \
--vpc-id vpc-aaaa1111 --peer-vpc-id vpc-bbbb2222 \
--peer-region us-west-2
# Accept the peering request from the peer side
aws ec2 accept-vpc-peering-connection \
--vpc-peering-connection-id pcx-0123456789abcdef0
# Add a route to the peer CIDR in a subnet route table
aws ec2 create-route \
--route-table-id rtb-1111 --destination-cidr-block 10.20.0.0/16 \
--vpc-peering-connection-id pcx-0123456789abcdef0
# Create a Transit Gateway and attach a VPC
aws ec2 create-transit-gateway --description "central-hub"
aws ec2 create-transit-gateway-vpc-attachment \
--transit-gateway-id tgw-0123456789abcdef0 \
--vpc-id vpc-aaaa1111 --subnet-ids subnet-1111
# Route a subnet to the Transit Gateway
aws ec2 create-route \
--route-table-id rtb-2222 --destination-cidr-block 10.0.0.0/8 \
--transit-gateway-id tgw-0123456789abcdef0