Skip to content
About Me
----

Advanced Routing: AWS Transit Gateway & AWS PrivateLink

Architect Key Takeaways

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-D
  1. 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.
  2. 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.

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.

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.


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.


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:

  1. 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).
  2. 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).
  3. 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.
  4. Inspect Subnet Association: Verify that the Transit Gateway VPC Attachment includes the specific Availability Zone subnets where your workloads are hosted.
  5. Security Group Egress/Ingress: Ensure the target instance’s Security Group allows traffic from VPC-A’s source CIDR.

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.