Lesson 2 of 5 VPC Connectivity and Hybrid Networking

Connecting Many Networks with AWS Transit Gateway

This lesson explains how AWS Transit Gateway, a Regional network hub, connects many VPCs, VPNs and Direct Connect gateways, replacing a mesh of peering connections with a hub-and-spoke design.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe how Transit Gateway attachments and route tables work.
  • Choose between peering and Transit Gateway.
  • Describe centralised inspection and egress designs.
  • Identify related options such as Cloud WAN.

How Transit Gateway works

AWS Transit Gateway is a regional network hub that connects many VPCs and on-premises networks. Each VPC, Site-to-Site VPN connection, Direct Connect gateway or SD-WAN connection is an attachment, and routing between attachments is transitive, so every attached network can reach every other one through the hub, replacing a mesh of peering connections.

Route tables on the transit gateway control which attachments can reach each other, which allows networks to be segmented. Transit gateways in different Regions connect through inter-Region peering, and a transit gateway can be shared with other accounts through AWS RAM. Equal-cost multi-path (ECMP) routing across several VPN tunnels aggregates their bandwidth. Transit Gateway is charged per attachment per hour plus per gigabyte of data processed.

The following diagram shows a transit gateway with several kinds of attachment.

AWS Transit Gateway as a regional hub. VPCs, Site-to-Site VPN connections and Direct Connect gateways are attachments, and routing between them is transitive, so each network reaches the others through the hub. Transit gateway route tables segment which attachments can reach each other, and inter-Region peering links hubs in different Regions.
Every attachment is reachable from every other by default; separate route tables restrict this, for example to keep development away from production.

Peering or Transit Gateway?

VPC peering and Transit Gateway both connect VPCs, but they suit networks of different sizes. Peering is a point-to-point connection between two VPCs. It has no hourly charge, only data transfer, and adds no extra hop, so it suits a few VPCs that need to talk to each other. Because it is not transitive, each VPC needs its own VPN or Direct Connect path to on premises.

Transit Gateway is a regional hub to which VPCs, VPN connections and Direct Connect gateways attach. Routing through it is transitive, so every attached VPC can reach every other and share one connection to on premises, and route tables on the transit gateway can separate traffic, for example keeping production and development apart. It is charged per attachment per hour plus per gigabyte processed, which is worthwhile once there are more than a handful of VPCs. The following table summarises the differences.

VPC peering
TopologyPoint to point
TransitiveNo
On-premises connectivityPer VPC
CostData transfer only
AWS Transit Gateway
TopologyHub and spoke
TransitiveYes
On-premises connectivityShared by every attached VPC
CostPer attachment hour plus per GB
Sort into groups

Peering or Transit Gateway?

Exam skills 3.4.1 · 4.4.3

Decide which option each statement describes or suits.

Log in to try this activity Interactive activities are free with an account.

Centralised designs

A transit gateway enables several centralised network designs. In an inspection VPC design, traffic between VPCs or to the internet is routed through AWS Network Firewall or third-party appliances behind a Gateway Load Balancer; appliance mode on the attachment keeps both directions of each flow on the same appliance, which stateful inspection requires.

In centralised egress, spoke VPCs send internet traffic to one egress VPC with NAT gateways, which simplifies control and reduces the number of NAT gateways, at the cost of transit gateway processing charges. Route table segmentation isolates environments, for example ensuring that production and development VPCs cannot reach each other while both can reach shared services.

Scenario questions

Centralised network designs

Exam skills 3.4.1 · 4.4.1

Choose the Transit Gateway design for each requirement.

Log in to try this activity Interactive activities are free with an account.

Related options

Two related options also connect or share networks. AWS Cloud WAN builds a global network across Regions and on-premises sites, managed through a central policy, which suits organisations with many Regions that would otherwise manage many transit gateways and peering connections.

VPC sharing, through AWS RAM, takes a different approach: a networking account owns a VPC and shares its subnets with other accounts, which launch their resources directly into those subnets. This reduces the number of VPCs that need to be connected at all, while each account still owns its own resources.

Worked example

Connecting a growing number of VPCs

A company started with two VPCs connected by peering. It now has 12 VPCs that all need to reach a shared-services VPC and the on-premises network, and each other in some cases.

VPC peering
Connections for 12 VPCs fully meshed66 peering connections
Transitive routingNo
On-premises VPN or Direct Connect shared by allNo
Segmentation (dev cannot reach prod)By omitting peerings
Transit Gateway
Connections for 12 VPCs fully meshed12 attachments
Transitive routingYes
On-premises VPN or Direct Connect shared by allYes
Segmentation (dev cannot reach prod)Route tables

Transit Gateway is the scalable answer. Peering remains a good choice for a single high-volume connection between two VPCs, because it has no per-GB processing charge.

Check yourself

How can a Transit Gateway stop development VPCs from reaching production VPCs?

Show answer

With separate Transit Gateway route tables: development attachments are associated with a route table that has no routes to the production attachments.

Exam Tips

Remember for the exam

  • For many VPCs and on-premises networks, use Transit Gateway.
  • To isolate groups of VPCs while sharing services, use multiple transit gateway route tables.
  • To inspect all traffic between VPCs with a firewall, use an inspection VPC behind the transit gateway with appliance mode.
  • To share one set of NAT gateways among many VPCs, use a centralised egress VPC through the transit gateway.
  • To connect transit gateways in different Regions, use transit gateway inter-Region peering.