Advanced Routing: AWS Transit Gateway & AWS PrivateLink
Master enterprise AWS routing: hub-and-spoke Transit Gateway (TGW) architecture, transitive routing mechanics, centralized inspection VPCs, and PrivateLink VPC endpoints.
Advanced Routing: AWS Transit Gateway & AWS PrivateLink
Section titled βAdvanced Routing: AWS Transit Gateway & AWS PrivateLinkβAs an enterprise cloud footprint expands from a single development account to dozens of AWS accounts containing hundreds of VPCs, traditional point-to-point connections break down. Operational complexity skyrockets, security policies become impossible to audit, and cross-VPC communication becomes brittle.
This guide explores the two modern networking technologies that solve enterprise multi-VPC scaling: AWS Transit Gateway (TGW) for transitive routing and AWS PrivateLink for eliminating public internet traversal.
1. The Scaling Problem: VPC Peering vs. AWS Transit Gateway
Section titled β1. The Scaling Problem: VPC Peering vs. AWS Transit GatewayβPEERING MESH (NON-TRANSITIVE) TRANSIT GATEWAY (HUB & SPOKE) VPC-A βββ VPC-B VPC-A VPC-B β β² β± β β β β β³ β βΌ βΌ β β± β² β βββββββββββββββββββββββββ VPC-C βββ VPC-D β AWS Transit Gateway β (N*(N-1)/2 complex connections) βββββββββββββββββββββββββ (No Transitive Routing Allowed) β² β² β β VPC-C VPC-DThe Inherent Limitations of VPC Peering:
Section titled βThe Inherent Limitations of VPC Peering:β- No Transitive Routing: If VPC-A peers with VPC-B, and VPC-B peers with VPC-C, traffic from VPC-A cannot transit through VPC-B to reach VPC-C. You are forced to establish an explicit peering link between VPC-A and VPC-C.
- Exponential Connection Growth: For $N$ VPCs, a full mesh requires $\frac{N(N-1)}{2}$ individual peering links:
- 10 VPCs = 45 peering links
- 50 VPCs = 1,225 peering links
- 100 VPCs = 4,950 peering links! Each link requires independent route table entries and security monitoring.
The Transit Gateway Solution:
Section titled βThe Transit Gateway Solution:βAWS Transit Gateway acts as a high-throughput Layer 3 Regional Cloud Router:
- Connects thousands of VPCs, on-premises Direct Connect connections, and VPNs through a central managed hub.
- Full support for Transitive Routing: Traffic from any spoke VPC reaches any other spoke or corporate data center according to centralized route tables.
- Cross-Region Peering: Interconnect Transit Gateways across multiple AWS regions using encrypted AWS backbone fiber.
2. Centralized Security Inspection VPC Architecture
Section titled β2. Centralized Security Inspection VPC ArchitectureβIn enterprise DevSecOps, security teams must inspect all traffic passing between VPCs (East-West traffic) and traffic bound for the public internet (North-South traffic).
[ Workload VPC 1 ] βββ [ Workload VPC 2 ] βββΌββ> [ AWS Transit Gateway ] [ Workload VPC 3 ] βββ β βΌ βββββββββββββββββββββββββββββββββββ β Central Inspection VPC β β βββ Network Firewall / WAF β β βββ Intrusion Detection (IDS) β β βββ Deep Packet Inspection (DPI)β ββββββββββββββββββ¬βββββββββββββββββ β (Clean Traffic Only) βΌ [ Internet / On-Premises ]By directing all Transit Gateway routes to a dedicated Centralized Inspection VPC, security appliances (like AWS Network Firewall or Palo Alto VM-Series) inspect and filter traffic before it reaches target production workloads or exits to the internet.
3. AWS PrivateLink: Eliminating Public Internet Traversal
Section titled β3. AWS PrivateLink: Eliminating Public Internet TraversalβWhen an EC2 instance, ECS container, or EKS pod in a private subnet needs to consume AWS services (e.g., S3, DynamoDB, Secrets Manager) or third-party SaaS APIs (Datadog, Snowflake), the legacy pattern required routing traffic through NAT Gateways out to the public internet.
AWS PrivateLink connects VPCs directly to AWS services and private APIs entirely within the private AWS network fabric:
| Endpoint Type | Implementation Layer | Target Services | Cost Model |
|---|---|---|---|
| Gateway Endpoint | Injected directly into Subnet Route Table | Amazon S3 and Amazon DynamoDB only | FREE (Zero hourly or data processing charges) |
| Interface Endpoint | Elastic Network Interface (ENI) with Private IP | All other AWS services (KMS, ECR, Secrets Mgr, SSM) | ~$7.20/month per AZ + $0.01/GB data processed |
[!TIP] FinOps Production Rule: Always deploy Gateway Endpoints for Amazon S3 and DynamoDB across all private subnet route tables. It is completely free, prevents private traffic from incurring heavy NAT Gateway data transfer fees ($0.045/GB), and protects data against external network sniffing.
4. Real-Time Production Triage Runbook
Section titled β4. Real-Time Production Triage RunbookβIncident: Transit Gateway Cross-VPC Traffic Fails with Packet Loss
Section titled βIncident: Transit Gateway Cross-VPC Traffic Fails with Packet LossβSymptom: Services in VPC-A cannot establish a TCP connection with services in VPC-B through Transit Gateway.
Triage Protocol:
- Check Spoke Route Tables: Verify VPC-A subnet route table has an entry directing VPC-Bβs CIDR (
10.200.0.0/16) to the Transit Gateway (tgw-xxxxxx). - Check Transit Gateway Route Table: Verify the TGW Route Table has an active route for VPC-Bβs CIDR pointing to VPC-Bβs attachment (
tgw-attach-xxxxxx). - Verify Return Routing: Networking is a two-way street. Ensure VPC-B has a return route pointing VPC-Aβs CIDR back to the Transit Gateway.
- Inspect Subnet Association: Verify that the Transit Gateway VPC Attachment includes the specific Availability Zone subnets where your workloads are hosted.
- Security Group Egress/Ingress: Ensure the target instanceβs Security Group allows traffic from VPC-Aβs source CIDR.
π§ Architect Knowledge Check
Section titled βπ§ Architect Knowledge Checkβ1. Why is an Interface VPC Endpoint considered superior from a security compliance standpoint compared to communicating over a NAT Gateway?
Answer: Communicating through a NAT Gateway requires traffic to traverse the public internet (even if encrypted via TLS), exposing requests to public routing hops and requiring public DNS resolution. With an Interface VPC Endpoint (AWS PrivateLink), traffic stays 100% inside the private AWS global network backbone. The service is represented as a private RFC 1918 IP address directly inside your subnet, completely removing public IP exposure.
2. Can an AWS Transit Gateway interconnect VPCs with overlapping CIDR blocks?
Answer: No, not directly. Standard IP routing requires unique destination CIDRs. If two VPCs have the same CIDR (e.g., both use
10.0.0.0/16), Transit Gateway cannot determine where to route packets. To interconnect overlapping VPCs, you must use AWS PrivateLink (exposing services via Network Load Balancers) or implement Source/Destination Network Address Translation (NAT) before traffic enters the Transit Gateway.