Segmenting and Inspecting Traffic with AWS Transit Gateway
This lesson explains how AWS Transit Gateway replaces a mesh of VPC peering connections with a Regional hub-and-spoke router whose route tables implement segmentation and inspection.
Learning outcomes
After completing this lesson, you will be able to:
- Identify the types of transit gateway attachment.
- Segment networks with route table association and propagation.
- Explain how appliance mode keeps inspection traffic symmetric.
- Describe multi-Region peering, sharing and cost considerations.
Attachments
A transit gateway is a Regional router that networks join through attachments. A VPC attachment places a network interface in one subnet in each Availability Zone that the VPC uses; traffic from an Availability Zone without an attachment subnet cannot use the transit gateway, so the attachment needs a subnet in every zone with workloads. Small dedicated attachment subnets keep the transit gateway's routing separate from the workloads' own route tables.
On-premises networks attach through a Site-to-Site VPN, where equal-cost multi-path routing (ECMP) across several tunnels aggregates bandwidth, or through a Direct Connect gateway over a transit virtual interface. Connect attachments run GRE tunnels with BGP to SD-WAN appliances, which suits organisations that already use an SD-WAN fabric. Peering attachments join transit gateways in other Regions or accounts. The following table summarises the attachment types.
| Attachment | Connects |
|---|---|
| VPC | A VPC, through a subnet in each Availability Zone used |
| Site-to-Site VPN | On-premises networks over IPsec, with ECMP for more bandwidth |
| Direct Connect gateway | On-premises networks over a transit VIF |
| Connect | SD-WAN appliances over GRE with BGP |
| Peering | Transit gateways in other Regions or accounts |
Route tables, association and propagation
Routing on a transit gateway is controlled by two independent choices for each attachment. Association decides which route table is consulted for traffic arriving from the attachment; each attachment is associated with exactly one route table. Propagation decides which route tables learn the attachment's routes, and therefore who can reach it; an attachment can propagate into several route tables. The default route table, which associates and propagates everything, gives full any-to-any connectivity, so segmented designs disable the defaults and manage the tables explicitly.
Segmentation follows from these two choices. Production VPCs are associated with a production route table and development VPCs with a development table. Shared services and the on-premises attachment propagate into both tables, while production and development propagate only into the shared services and on-premises tables. Production and development can then both reach shared networks, but neither can reach the other, because neither table contains the other's routes.
Static routes override or supplement propagated ones, and a blackhole route drops traffic to a range explicitly. When several routes match, the most specific prefix wins; for equally specific routes, static routes are preferred over propagated ones, and among propagated routes, VPC routes are preferred over Direct Connect routes, which are preferred over VPN routes. This order is why a VPN can serve as a backup to Direct Connect on the same transit gateway.
Inspection with appliance mode
To force traffic through a firewall, spoke route tables send a default route to the inspection VPC attachment, and the inspection VPC's route table returns traffic to the spokes. Stateful firewalls must see both directions of a flow, so appliance mode is enabled on the inspection VPC attachment; it keeps a flow on the same Availability Zone's firewall for its whole lifetime.
Multi-Region, sharing and cost
Transit gateways are Regional, and inter-Region peering joins them over the AWS backbone, with traffic encrypted. No dynamic routing runs across a peering, so each side needs static routes to the other's networks, which becomes laborious as the number of Regions grows; Cloud WAN addresses that problem. A transit gateway is created in a networking account and shared through AWS RAM with workload accounts, which create attachments that the networking account accepts, manually or automatically.
Transit gateways are charged per attachment per hour and per gigabyte processed. For most traffic this is worth the simplicity, but very heavy flows between two particular VPCs, such as a data pipeline moving terabytes a day, can be cheaper over a VPC peering connection added alongside the transit gateway, because peering within an Availability Zone has no processing charge. Each VPC attachment supports up to 100 Gbps per Availability Zone, while a standard VPN tunnel carries up to 1.25 Gbps (5 Gbps for a large bandwidth tunnel), so higher VPN throughput needs ECMP across several tunnels.
Segmenting production and development
Production and development VPCs share one transit gateway. Both must reach the shared-services VPC and on premises, but never each other. The design uses three route tables, with association deciding which table an attachment uses and propagation deciding which tables learn its routes:
Route table Associated attachments Propagated routes from
----------- ------------------------- ---------------------------------
rt-prod prod VPCs shared-services VPC, DX gateway
rt-dev dev VPCs shared-services VPC, DX gateway
rt-shared shared-services VPC, prod VPCs, dev VPCs
DX gateway attachmentaws ec2 associate-transit-gateway-route-table --transit-gateway-route-table-id $RT_PROD \
--transit-gateway-attachment-id $ATT_PROD_VPC1
aws ec2 enable-transit-gateway-route-table-propagation --transit-gateway-route-table-id $RT_PROD \
--transit-gateway-attachment-id $ATT_SHARED
aws ec2 enable-transit-gateway-route-table-propagation --transit-gateway-route-table-id $RT_SHARED \
--transit-gateway-attachment-id $ATT_PROD_VPC1A packet from a production VPC is looked up in rt-prod, which has no route to development CIDRs, so it is dropped at the transit gateway. Shared services can answer both because rt-shared knows every spoke. Disabling the default route table association and propagation on the transit gateway is essential; otherwise new attachments land in a table that connects everything.
Why is appliance mode enabled on the inspection VPC's transit gateway attachment?
Show answer
It keeps both directions of a flow in the same Availability Zone, so a stateful firewall sees the request and the response.
Exam Tips
Remember for the exam
- To segment production and development while both reach shared services, use multiple TGW route tables.
- For a stateful firewall in an inspection VPC behind a transit gateway, enable appliance mode.
- For more VPN bandwidth to a transit gateway, use several tunnels with ECMP.
- Inter-Region TGW peering requires static routes.
- For very heavy traffic between two particular VPCs, VPC peering can be cheaper than a transit gateway.
- Share a transit gateway with other accounts through AWS RAM.