Sub topic 7
Pointing VPC routes at the transit gateway
This chapter assumes you know how VPC route tables work, have created a transit gateway, and have attached a VPC to it. Attaching a VPC does not make traffic flow by itself. Each VPC subnet route table still needs an entry that sends the other VPCs' traffic to the transit gateway.
Two route tables, two jobs
Traffic crosses two route tables on its way between VPCs.
- The VPC route table decides whether a packet leaves the subnet toward the transit gateway.
- The transit gateway route table decides which attachment receives the packet next.
Propagation and association fill in the second table. You write the first table yourself, because AWS does not add routes to your VPC route tables for a transit gateway.
Add the route
This command sends traffic for VPC B's range (10.1.0.0/16) to the transit gateway. Run it against the route table of each subnet in VPC A that needs to reach VPC B.
aws ec2 create-route \
--route-table-id rtb-0123456789abcdef0 \
--destination-cidr-block 10.1.0.0/16 \
--transit-gateway-id tgw-0123456789abcdef0Repeat the step in VPC B with VPC A's CIDR (10.0.0.0/16), or return traffic will have no path back. Each side needs its own route.
You can check the result with describe-route-tables:
aws ec2 describe-route-tables \
--route-table-ids rtb-0123456789abcdef0 \
--query "RouteTables[].Routes[].[DestinationCidrBlock,TransitGatewayId,State]" \
--output tableThe route should show active. A route shows blackhole when its target no longer exists, for example after the attachment is deleted.
Choosing the destination
You have two common choices.
| Destination | Effect | Trade-off |
|---|---|---|
| One route per remote VPC CIDR | Only listed networks use the transit gateway | More entries to maintain, tighter control |
| A broad route such as `10.0.0.0/8` or `0.0.0.0/0` | One entry covers many networks | Easier to manage, but sends more traffic to the hub |
The VPC's local route (its own CIDR) always wins over a broader route, because the most specific match is used. A summary route therefore cannot hijack traffic inside the VPC.
You can also use a managed prefix list as the destination. Several routes can then share one list, and you edit the list once instead of every route table.
Common mistakes
- Missing the return route. Requests arrive but replies are lost, so connections time out.
- Wrong route table. A subnet uses its associated route table, or the main route table if none is associated. Edit the one the subnet actually uses.
- No attachment in the subnet's Availability Zone. A transit gateway only delivers traffic into an Availability Zone where the VPC attachment has a subnet. Traffic bound for a zone without an attachment subnet is dropped.
- Security rules. Security groups and network ACLs still apply. Allow the remote CIDR in both.
Exercise
Instances in VPC A (10.0.0.0/16) can send packets to VPC B (10.1.0.0/16), but connections never complete. Both VPCs are attached and the transit gateway route table has both CIDRs. What is the most likely missing piece, and where do you add it?
Show answer
The return route. VPC B's subnet route table needs an entry for 10.0.0.0/16 targeting the transit gateway, so replies can get back to VPC A. Also check that the instance's security group and network ACL allow traffic from the remote CIDR.