Sub topic 1
Connecting VPCs with AWS Transit Gateway and AWS PrivateLink
Prerequisites
Assume you understand CIDR blocks, subnets, VPC route tables, security groups, network ACLs, and basic AWS CLI usage. You should also know that a Network Load Balancer distributes traffic to targets.
VPC building blocks you will rely on
A VPC is an isolated virtual network. A subnet is an IP range inside one Availability Zone. Each subnet uses a route table, which contains destinations and next hops. A route such as 10.1.0.0/16 → transit gateway tells AWS where to send matching traffic.
Three ways to connect VPCs and when to use each
- VPC peering creates a direct connection between two VPCs. Use it for a small number of simple connections.
- Transit Gateway is a regional network hub. Use it for routing between many VPCs, VPNs, or Direct Connect connections.
- PrivateLink exposes a particular service through private interface endpoints. Use it when consumers need the service, not access to the provider's whole network.
Why VPC peering stops scaling
Peering is non-transitive. If VPC A peers with VPC B, and VPC B peers with VPC C, A cannot reach C through B. Each required pair needs its own peering connection and route entries. The number of connections grows quickly as networks increase.
> callout note > Peering routes are also limited to the connected VPCs. A peering connection does not automatically provide transit routing.
Transit Gateway as a regional router
A Transit Gateway provides a managed hub within one AWS Region. VPC attachments connect spokes to the hub. Transit Gateway route tables determine which attachments can reach one another. The VPC route table must also send the destination CIDR to the gateway.
Attaching VPCs to a transit gateway
Create an attachment with one subnet in each selected Availability Zone. These subnets provide the attachment's network interfaces.
aws ec2 create-transit-gateway-vpc-attachment \
--transit-gateway-id tgw-0123456789abcdef0 \
--vpc-id vpc-0aaa1111bbb22222c \
--subnet-ids subnet-0aaa1111 subnet-0bbb2222Route tables, association, and propagation
An attachment is associated with one Transit Gateway route table. That table decides its outbound routing. Propagation copies routes for an attachment's CIDR into a route table. Disable default behavior when you need explicit segmentation, then associate and propagate only the intended attachments.
Exercise
Why must both the VPC route table and the Transit Gateway route table contain suitable routes?
Show answer
The VPC route table sends traffic to the gateway, and the Transit Gateway route table chooses the destination attachment.