Connecting VPCs with Peering and AWS Transit Gateway
This lesson explains how VPC peering connects pairs of VPCs and how AWS Transit Gateway connects many VPCs and on-premises networks through a hub.
Learning outcomes
After completing this lesson, you will be able to:
- Explain VPC peering and its limits.
- Describe transit gateway attachments and route tables.
- Segment networks with Transit Gateway.
VPC peering
A VPC peering connection connects two VPCs, in the same or different accounts and Regions, so instances communicate using private IP addresses over the AWS network. One side requests and the other accepts. Both VPCs' route tables need routes to the other's CIDR through the peering connection, and security groups must allow the traffic (security groups in a same-Region peered VPC can be referenced). Peering is non-transitive: if A peers with B and B with C, A cannot reach C through B, and A cannot use B's internet gateway, NAT gateway or VPN. CIDRs must not overlap. Peering has no hourly charge, and data transfer within an AZ over peering is free, making it cost-effective for a few high-volume connections. DNS resolution of public hostnames to private IPs across the peering can be enabled.
Peering requirements
AWS Transit Gateway
A transit gateway is a Regional hub to which attachments connect: VPCs (through ENIs in a subnet per AZ), Site-to-Site VPN connections, Direct Connect gateways, Transit Gateway Connect (SD-WAN) and peering with transit gateways in other Regions. Transit gateway route tables control routing: each attachment is associated with one route table (which routes its outbound traffic), and attachments propagate their routes into route tables, or static routes are added. Multiple route tables segment traffic, for example production VPCs that cannot reach development VPCs but all can reach shared services. VPC route tables must also send the destination CIDRs to the transit gateway. Transit Gateway is shared across accounts with AWS RAM, is charged per attachment-hour and per GB processed, and supports Flow Logs.
The following diagram shows three Transit Gateway route tables that separate production from development.

Peering or Transit Gateway?
Segmenting with Transit Gateway
A company connects 20 VPCs and its data centre. Production VPCs must reach shared services and on premises but not development VPCs. The network team creates three TGW route tables: prod, dev and shared. Production attachments are associated with prod, which has propagations from shared services and the VPN only; development attachments use dev, with propagations from shared services only; shared services and the VPN use shared, which receives propagations from everything. Each VPC's route table sends 10.0.0.0/8 to the transit gateway.
Can VPC A reach VPC C through VPC B over peering?
Show answer
No. Peering is non-transitive; A and C need their own peering or a transit gateway.
Exam Tips
Remember for the exam
- VPC peering is non-transitive and requires non-overlapping CIDRs and routes on both sides.
- Peered VPCs cannot use each other's IGW, NAT or VPN.
- Transit Gateway: associate each attachment with a route table and propagate or add routes.
- VPC route tables must point to the transit gateway too.
- Multiple TGW route tables segment environments.