Sub topic 12
Peering and Transit Gateway cost trade-offs
This chapter assumes you know VPC routing, route tables, and the inter-AZ and cross-region charges from earlier chapters. Prices below are typical us-east-1 list prices. Check the pricing pages for your Region before you decide.
How the two options charge
VPC peering is a direct link between two VPCs. It has no hourly fee and no per-GB processing fee. You pay only standard data transfer:
- Traffic that stays in the same AZ is free.
- Traffic that crosses AZs costs $0.01/GB in each direction.
- Traffic over a cross-region peering connection is billed at inter-region rates.
Transit Gateway (TGW) is a managed hub that many VPCs and on-premises links attach to. It has two charges:
- An hourly fee per attachment, about $0.05 per hour.
- A data processing fee of about $0.02/GB for traffic sent into the gateway.
| Item | VPC peering | Transit Gateway |
|---|---|---|
| Hourly cost | None | Per attachment |
| Per-GB processing | None | About $0.02/GB |
| Same-AZ traffic | Free | Pays the processing fee |
| Transitive routing | No | Yes |
| Scales to many VPCs | Poorly (full mesh) | Well (hub and spoke) |
A worked comparison
Suppose two VPCs exchange 10 TB (10,240 GB) a month, mostly inside one AZ.
- Peering costs about $0 for same-AZ traffic.
- TGW costs 10,240 × $0.02 = $204.80 in processing. Two attachments add 2 × $0.05 × 730 hours = $73. The total is about $278 a month.
For one high-volume pair of VPCs, peering is far cheaper. TGW earns its cost when you have many VPCs. Ten VPCs in a full mesh need 45 peering connections and 45 sets of routes. A hub needs 10 attachments.
Creating a peering link
This example peers two VPCs in one account and Region, then routes traffic both ways. Replace the IDs with your own.
aws ec2 create-vpc-peering-connection \
--vpc-id vpc-0123456789abcdef0 \
--peer-vpc-id vpc-0fedcba9876543210
aws ec2 accept-vpc-peering-connection \
--vpc-peering-connection-id pcx-0123456789abcdef0
aws ec2 create-route \
--route-table-id rtb-0123456789abcdef0 \
--destination-cidr-block 10.1.0.0/16 \
--vpc-peering-connection-id pcx-0123456789abcdef0
aws ec2 create-route \
--route-table-id rtb-0fedcba9876543210 \
--destination-cidr-block 10.0.0.0/16 \
--vpc-peering-connection-id pcx-0123456789abcdef0Each VPC needs a route to the other's CIDR. The CIDR blocks must not overlap.
Common errors and gotchas
- Peering is not transitive. If A peers with B and B peers with C, A cannot reach C through B. Teams often add TGW only to fix this, then pay processing fees on all traffic.
- Cross-AZ peering traffic is still billed. Address the peer by a private IP in the same AZ where you can. Use AZ IDs (for example
use1-az1), because AZ names map to different physical zones in different accounts. - TGW does not remove inter-AZ cost. The gateway adds its own processing fee on top of any cross-AZ pattern in your application.
- Idle attachments still bill hourly. Remove attachments for retired VPCs.
- Shared services create heavy flows. A central logging or egress VPC behind TGW sends all its bytes through the gateway. Measure this with Flow Logs before choosing a hub.
Exercise
Two VPCs in the same AZ exchange 20 TB (20,480 GB) a month. Roughly how much more does TGW cost than peering for the data processing alone, at $0.02/GB?
Show answer
About $409.60 a month (20,480 GB × $0.02). Peering charges nothing for same-AZ traffic. TGW attachment hourly fees add to the gap.