jajera · tgw-policy-based-routing-walkthrough
TGW Policy-Based Routing
Published walkthrough for the
jajera/tgw-policy-based-routing
lab — a three-account hub-and-spoke demo that proves destination-only Transit Gateway
routing versus Policy-Based Routing (same Spoke B IP, TCP/443 via Hub, TCP/80 direct).
Three accounts
Owns the Transit Gateway, Hub VPC, internet egress, and the optional Hub forwarder.
Sandbox Spoke A clientClient VPC with the policy table on its TGW attachment — where PBR decides the path.
Shared services Spoke B listenerHTTP :80 / HTTPS :443 on one private IP — destination IP alone cannot explain the split.
What this covers
The pattern. Classic transit gateway route tables forward by destination prefix only. A policy table evaluates an ordered rule set (source/destination CIDR, protocol, ports) and selects a target route table — first match wins; no match is implicit deny. Destination routing still runs inside the table PBR selects.
The lab. Terraform in
jajera/tgw-policy-based-routing
provisions the topology. This site is the operator walkthrough and concept docs — clone and
apply the lab, then follow Deploy and prove.
Lab rule 100 matches destination TCP/443 → Steer via Hub. Rule 200 is a catch-all → Direct. Without the catch-all,
:80and ICMP drop (implicit deny).
Read in this order
Last verified against AWS Transit Gateway documentation on 2026-08-06. Feature availability, limits, and behaviour can change — check current AWS docs before relying on any claim here.
Prerequisites in brief
- Terraform >= 1.6 and AWS provider >= 5.0 (in the lab repo)
- Profiles
network,sandbox, andshared-services(three distinct accounts) - Session Manager plugin
- Region examples:
ap-southeast-2
Full detail in the walkthrough.
The lab is billable while running: TGW attachments, NAT, EC2, flow logs. Follow teardown in the walkthrough; confirm
terraform state listis empty.