โšก
Zero to Platform Architect2026
Phase 1: Multi-Cloud Networking

Lesson 2: Multi-Account Transit Gateway & Centralized Egress

๐Ÿง  The Concept (Explain Like Iโ€™m 5)

Imagine an enterprise with 50 office buildings (AWS Accounts and VPCs) scattered across a metropolitan area:

  • The Mesh Nightmare (VPC Peering): If every building needs to talk to every other building, you have to dig private underground tunnels between every single pair of buildings. For 50 buildings, that requires 1,225 separate tunnels. If Building 12 changes its address, you have to reprogram the GPS routing in 49 other buildings. Worse, AWS VPC Peering is Non-Transitive: you cannot drive through Building B to get to Building C!
  • The Grand Central Station (AWS Transit Gateway - TGW): You build a single, ultra-high-speed central railway station in the middle of the city (The Network Hub). Every building digs a single tunnel to the Hub. When Building A wants to send a package to Building C, it sends it to the Hub, and the Hub switches it instantly to Building C.
  • Centralized Egress (The Shared Delivery Fleet): Instead of every building hiring their own expensive private international courier truck (NAT Gateway at $32/month each ร— 3 AZs = $96/mo per building), every building sends their outgoing international mail through the Hubโ€™s single shared courier facility, slashing your enterprise cloud networking bill by up to 80%!

๐Ÿงฎ The Scalability Math: VPC Peering vs. Transit Gateway

Why do enterprises abandon VPC Peering as soon as they grow beyond 5 accounts?

๐Ÿ“ Peering Connections Needed = (N(N-1)) / 2

Number of VPCs (N)   VPC Peering Tunnels Needed   AWS Transit Gateway Attachments
---------------------------------------------------------------------------------
5 VPCs               10 peerings                  5 attachments
20 VPCs              190 peerings                 20 attachments
50 VPCs              1,225 peerings               50 attachments
100 VPCs             4,950 peerings               100 attachments (Linear O(N)!)

Critical Architectural Limitations of VPC Peering:

  1. Hard Limit of 125 Active Peerings: An AWS VPC cannot have more than 125 active peering connections. A large enterprise with 200 VPCs cannot physically connect using VPC Peering.
  2. Non-Transitivity: If VPC A is peered with VPC B, and VPC B is peered with VPC C, VPC A cannot reach VPC C through VPC B. Every connection requires a direct 1:1 link.
  3. Transit Gateway Scales to 5,000 Attachments: A single TGW supports up to 5,000 VPC, VPN, and Direct Connect attachments, handling up to 50 Gbps burst throughput per attachment!

๐Ÿ—บ๏ธ Visual Architecture: Centralized Egress Hub-and-Spoke Topology

flowchart TD
    Internet(("๐ŸŒ Public Internet")) <--> IGW["AWS Internet Gateway (IGW)"]

    subgraph NetHubAccount ["๐Ÿข Central Networking Account (The Hub)"]
        subgraph HubVPC ["Hub Egress / Inspection VPC (10.0.0.0/16)"]
            NAT["Central NAT Gateway (AZ-a / AZ-b)"]
            FW["AWS Network Firewall (Deep Packet Inspection)"]
            HubTGWSubnet["Dedicated TGW Subnets (/28)"]
        end
        TGW["<b>AWS Transit Gateway (TGW)</b><br/>โ€ข Hub Route Table (0.0.0.0/0 -> NAT)<br/>โ€ข Spoke Route Table (Isolates Dev from Prod)"]
    end

    subgraph SpokeDev ["๐Ÿ“ฆ Workload Account: Dev (10.1.0.0/16)"]
        VPC_Dev["Private Subnets Only (No IGW! No NAT!)"]
        AppDev["EKS Dev Cluster"] --> VPC_Dev
    end

    subgraph SpokeProd ["๐Ÿ“ฆ Workload Account: Prod (10.2.0.0/16)"]
        VPC_Prod["Private Subnets Only (No IGW! No NAT!)"]
        AppProd["EKS Prod Cluster"] --> VPC_Prod
    end

    IGW <--> NAT
    NAT <--> FW
    FW <--> HubTGWSubnet
    HubTGWSubnet <--> TGW

    TGW -.->|"Shared via AWS RAM"| VPC_Dev
    TGW -.->|"Shared via AWS RAM"| VPC_Prod

๐Ÿ”ฌ Under the Hood: TGW Route Tables (Associations vs. Propagations)

A Transit Gateway is not a dumb network switch; it is a virtual cloud router containing multiple isolated route tables. This enables Network Segmentation (VRF - Virtual Routing and Forwarding):

flowchart LR
    DevAttach["Dev VPC Attachment"] --> DevRT["<b>Spoke Route Table</b><br/>โ€ข 10.0.0.0/8 -> TGW<br/>โ€ข 0.0.0.0/0 -> Hub Egress"]
    ProdAttach["Prod VPC Attachment"] --> ProdRT["<b>Spoke Route Table</b><br/>โ€ข 10.0.0.0/8 -> TGW<br/>โ€ข 0.0.0.0/0 -> Hub Egress"]
    
    HubAttach["Hub Egress Attachment"] --> HubRT["<b>Hub Route Table</b><br/>โ€ข 10.1.0.0/16 -> Dev<br/>โ€ข 10.2.0.0/16 -> Prod"]

The Difference Between Association and Propagation:

  • Association (Ingress Direction): Dictates which TGW Route Table a VPC attachment uses when traffic enters the Transit Gateway. Each attachment can associate with exactly one TGW Route Table.
  • Propagation (Egress Direction): Dictates which TGW Route Tables automatically learn the CIDR routes of that VPC. An attachment can propagate routes to multiple TGW Route Tables.

Enforcing Zero-Trust Segmentation

Platform architects create two distinct TGW Route Tables:

  1. Spoke-Route-Table: Associated with Dev and Prod VPCs. Contains only:
    • 0.0.0.0/0 โ†’ Hub Egress VPC Attachment
    • Notice: Dev VPC routes are NOT propagated here! Therefore, Dev cannot physically route packets to Prod, enforcing security compliance at Layer 3!
  2. Hub-Route-Table: Associated with the Hub Egress VPC. Propagates all Spoke VPC CIDRs (10.1.0.0/16, 10.2.0.0/16) so return traffic from the internet can find its way back!

๐Ÿ›ฃ๏ธ Packet Journey: From Private EKS Pod to GitHub

Trace the exact hop-by-hop journey of a packet when a private Pod in Spoke VPC Dev downloads a container image from GitHub (140.82.121.4):

sequenceDiagram
    autonumber
    actor Pod as ๐Ÿ“ฆ Private Pod (10.1.5.12)
    participant SpokeRT as ๐Ÿงญ Spoke VPC Route Table
    participant TGW as ๐Ÿ”„ AWS Transit Gateway
    participant TGW_RT as ๐Ÿงญ TGW Spoke Route Table
    participant HubVPC as ๐Ÿข Hub Egress VPC (10.0.1.50)
    participant NAT as ๐Ÿ›ก๏ธ Central NAT Gateway (Pub Subnet)
    participant IGW as ๐ŸŒ Internet Gateway
    participant WWW as ๐Ÿ™ GitHub API (140.82.121.4)

    Pod->>SpokeRT: 1. Send TCP SYN to 140.82.121.4
    SpokeRT->>TGW: 2. Matches default route 0.0.0.0/0 -> tgw-attach-dev
    TGW->>TGW_RT: 3. Evaluates Spoke-Route-Table: 0.0.0.0/0 -> tgw-attach-hub
    TGW->>HubVPC: 4. Delivers packet to Hub VPC TGW ENI interface
    HubVPC->>NAT: 5. Routed to Central NAT Gateway (10.0.1.100)
    NAT->>IGW: 6. Source NAT (SNAT): Translates 10.1.5.12 to Public Elastic IP (54.239.x.x)
    IGW->>WWW: 7. Packet exits AWS onto public internet fiber!
    WWW-->>IGW: 8. GitHub responds with TCP SYN-ACK
    IGW-->>NAT: 9. Elastic IP receives response packet
    NAT-->>HubVPC: 10. Reverse NAT: Restores destination IP to 10.1.5.12
    HubVPC-->>TGW: 11. Hub Route Table matches 10.1.0.0/16 -> tgw-attach-dev
    TGW-->>Pod: 12. Packet delivered to Pod with zero packet loss! โœ…

๐Ÿ›ก๏ธ Enterprise Next-Gen Firewall Insertion: AWS GWLB & TGW Appliance Mode

In regulated enterprise networks (PCI-DSS, HIPAA, FedRAMP), simply routing traffic to a NAT Gateway is insufficient. All East-West (VPC-to-VPC) and North-South (Internet Egress/Ingress) traffic must undergo Deep Packet Inspection (DPI) through Next-Generation Firewalls (NGFW) such as Palo Alto Networks VM-Series, Fortinet FortiGate, or Check Point.

flowchart TD
    subgraph InspectionVPC ["๐Ÿข Central Inspection & Egress Hub VPC"]
        TGW_Attach["TGW Attachment Subnet<br/><b>appliance_mode_support = enable</b>"]
        GWLBe["GWLB Endpoint (GWLBe)<br/>(Interface Endpoint ENI)"]
        GWLB["<b>AWS Gateway Load Balancer (GWLB)</b><br/>L3 Transparent Gateway + L4 Proxy"]
        
        subgraph FirewallFleet ["Stateful Firewall Appliance Fleet"]
            FW1["๐Ÿ›ก๏ธ Palo Alto VM-Series (AZ-a)<br/>GENEVE UDP 6081 Listener"]
            FW2["๐Ÿ›ก๏ธ Palo Alto VM-Series (AZ-b)<br/>GENEVE UDP 6081 Listener"]
        end

        NAT_GW["Central NAT Gateway (Pub Subnet)"]
        IGW["AWS Internet Gateway (IGW)"]
    end

    SpokeTraffic["๐Ÿ“ฆ Outbound Spoke Packet<br/>(Src: 10.1.5.12, Dst: 140.82.121.4)"] --> TGW_Attach
    TGW_Attach -->|"Route 0.0.0.0/0 -> vpce-gwlb"| GWLBe
    GWLBe -->|"AWS Hyperplane Fabric"| GWLB
    GWLB -->|"GENEVE Encapsulation (UDP 6081)"| FW1
    FW1 -.->|"DPI & Threat Inspection Approved"| GWLB
    GWLB --> GWLBe
    GWLBe -->|"Route 0.0.0.0/0 -> nat-gw"| NAT_GW
    NAT_GW --> IGW --> Internet(("๐ŸŒ Public Internet"))

1. The Protocol: GENEVE Encapsulation (RFC 8926)

Standard load balancers (ALB/NLB) cannot act as transparent network firewalls because:

  • ALB terminates Layer 7: It strips original IP headers and replaces the source IP with the ALBโ€™s internal IP.
  • NLB changes TCP states: Firewalls must see raw, untouched IP packets without NAT overhead.

How AWS GWLB Solves This:

  1. GWLB operates as a bump-in-the-wire transparent Layer 3 gateway and Layer 4 load balancer.
  2. When GWLB receives a raw IP packet, it does NOT alter the inner packet. Instead, it encapsulates the entire packet inside a GENEVE (Generic Network Encapsulation - RFC 8926) header over UDP port 6081.
  3. The GENEVE header includes TLV (Type-Length-Value) metadata (Attachment ID, Flow Cookie).
  4. The firewall appliance decapsulates the GENEVE frame, inspects the raw payload for intrusion patterns, re-encapsulates the frame into GENEVE UDP 6081, and returns it to GWLB.

2. The Asymmetric Routing Catastrophe & TGW Appliance Mode

Stateful firewalls (Palo Alto, Fortinet) maintain an in-memory session table. They require bidirectional symmetry: both outbound requests and inbound return packets MUST traverse the exact same firewall instance.

The Catastrophe Without Appliance Mode:

  1. Outbound Flow: A pod in Spoke AZ-a sends a packet. The Transit Gateway hashes the flow to Firewall 1 in Hub AZ-a. Firewall 1 creates a state table entry (TCP SYN seen) and permits the packet.
  2. Return Flow: The return packet arrives from the internet. When TGW forwards the return packet to the Spoke, TGWโ€™s default multi-AZ ECMP hashing evaluates the return flow independently and delivers it to Firewall 2 in Hub AZ-b.
  3. The Outage: Firewall 2 has no record of the initial TCP handshake! Seeing a SYN-ACK or ACK without a prior SYN, Firewall 2 classifies the packet as an attack and drops it immediately (TCP Out-of-State / Reset). The connection freezes!

The Architectural Solution: TGW Appliance Mode

# Enable Appliance Mode on the Central Inspection VPC Attachment
aws ec2 modify-transit-gateway-vpc-attachment \
    --transit-gateway-attachment-id tgw-attach-0123456789abcdef0 \
    --options ApplianceModeSupport=enable
  • When ApplianceModeSupport=enable is configured, Transit Gateway guarantees that for the entire duration of a bidirectional TCP/UDP flow, traffic in both directions is symmetrically routed through the exact same Elastic Network Interface (ENI) in the exact same Availability Zone.

3. Ingress Inspection Pattern (Edge Route Table Association)

To inspect traffic arriving from the public internet bound for internal workloads:

  1. Create a specialized route table and associate it with the Internet Gateway (IGW) using an Edge Association.
  2. Route incoming traffic destined for the public workload subnets to the GWLB Endpoint (vpce-xxx):
# Ingress Edge Route Table attached to Internet Gateway
resource "aws_route_table" "igw_edge_rt" {
  vpc_id = aws_vpc.hub_inspection.id

  # Redirect all traffic destined for Public ALB subnets through the GWLB Endpoint first!
  route {
    cidr_block           = "10.0.10.0/24" # Public ALB Subnet CIDR
    vpc_endpoint_id      = aws_vpc_endpoint.gwlb_endpoint_az_a.id
  }

  tags = { Name = "igw-edge-inspection-route-table" }
}

resource "aws_route_table_association" "igw_edge" {
  gateway_id     = aws_internet_gateway.hub_igw.id
  route_table_id = aws_route_table.igw_edge_rt.id
}

๐Ÿ’ฐ FinOps Calculation: The $100,000 NAT Gateway Problem

An AWS NAT Gateway costs:

  • Hourly Base Fee: $0.045 per hour โ‰ˆ $32.85 per month.
  • Data Processing Fee: $0.045 per Gigabyte processed.

The Math: Distributed NAT vs. Centralized TGW Egress

Assume an enterprise with 50 AWS Workload Accounts, each deployed across 3 Availability Zones (150 VPC subnets), processing 10 Terabytes of outbound traffic per month.

Option A: Distributed NAT Gateways (1 per AZ per Account)

  • NAT Gateway Base Fees: 50 accounts ร— 3 AZs ร— $32.85 = $4,927.50/month ($59,130/year just to keep them turned on!).
  • NAT Data Processing: 10,000 GB ร— $0.045 = $450/month.
  • Total Option A Cost: $5,377.50/month ($64,530/year).

Option B: Centralized Egress with AWS Transit Gateway

  • NAT Gateway Base Fees: Only 3 Central NAT Gateways in the Hub! 3 ร— $32.85 = $98.55/month.
  • NAT Data Processing: 10,000 GB ร— $0.045 = $450/month.
  • TGW Attachment Fees: 50 VPC attachments ร— $0.05/hr ร— 730 = $1,825/month.
  • TGW Data Processing Fee: 10,000 GB ร— $0.02 = $200/month.
  • Total Option B Cost: $2,573.55/month ($30,882/year).
  • Net Annual Savings: Over $33,600+ every single year, plus centralized firewall compliance!

๐Ÿ’ป Production Manifest: Provisioning Transit Gateway with Terraform

1. In Central Networking Account: TGW & RAM Share (tgw.tf)

# Create Central Transit Gateway
resource "aws_ec2_transit_gateway" "main" {
  description                     = "Enterprise Transit Gateway Hub"
  auto_accept_shared_attachments = "enable"
  default_route_table_association = "disable" # Explicit route tables only!
  default_route_table_propagation = "disable"
  
  tags = {
    Name        = "enterprise-tgw-hub"
    Environment = "Production"
  }
}

# Share TGW with all accounts in AWS Organization via AWS RAM
resource "aws_ram_resource_share" "tgw_share" {
  name                      = "tgw-organization-share"
  allow_external_principals = false
}

resource "aws_ram_resource_association" "tgw_assoc" {
  resource_arn       = aws_ec2_transit_gateway.main.arn
  resource_share_arn = aws_ram_resource_share.tgw_share.arn
}

resource "aws_ram_principal_association" "org_assoc" {
  principal          = "arn:aws:organizations::123456789012:organization/o-enterprise123"
  resource_share_arn = aws_ram_resource_share.tgw_share.arn
}

# Attach Central Inspection & Egress Hub VPC to TGW with APPLIANCE MODE ENABLED
resource "aws_ec2_transit_gateway_vpc_attachment" "hub_inspection_attach" {
  transit_gateway_id = aws_ec2_transit_gateway.main.id
  vpc_id             = aws_vpc.hub_inspection.id
  subnet_ids         = aws_subnet.hub_tgw_subnets[*].id

  # CRITICAL: Enforce symmetric flow hashing for stateful firewall appliances
  appliance_mode_support = "enable"

  tags = {
    Name        = "hub-inspection-tgw-attachment"
    Environment = "Production"
  }
}

# Gateway Load Balancer (GWLB) for Transparent Firewall Fleet Insertion
resource "aws_lb" "firewall_gwlb" {
  name               = "hub-firewall-gwlb"
  load_balancer_type = "gateway"
  subnets            = aws_subnet.firewall_subnets[*].id
  enable_cross_zone_load_balancing = true

  tags = { Name = "hub-security-gwlb" }
}

# GWLB Target Group encapsulating traffic via GENEVE (UDP Port 6081)
resource "aws_lb_target_group" "firewall_target_group" {
  name        = "firewall-geneve-tg"
  port        = 6081
  protocol    = "GENEVE"
  vpc_id      = aws_vpc.hub_inspection.id
  target_type = "ip"

  health_check {
    port     = 80 # Or dedicated firewall management health probe port
    protocol = "TCP"
    interval = 10
  }
}

# GWLB VPC Endpoint Service (exposes GWLB to VPC route tables)
resource "aws_vpc_endpoint_service" "gwlb_service" {
  acceptance_required        = false
  gateway_load_balancer_arns = [aws_lb.firewall_gwlb.arn]
}

# GWLB Endpoints (GWLBe) instantiated in each inspection subnet
resource "aws_vpc_endpoint" "gwlb_endpoint" {
  count             = 2
  vpc_id            = aws_vpc.hub_inspection.id
  service_name      = aws_vpc_endpoint_service.gwlb_service.service_name
  vpc_endpoint_type = "GatewayLoadBalancer"
  subnet_ids        = [aws_subnet.inspection_subnets[count.index].id]

  tags = { Name = "gwlb-endpoint-az-${count.index}" }
}

2. In Workload Account: Attaching VPC to Shared TGW (spoke_attachment.tf)

# Dedicated /28 Subnet per AZ for TGW ENIs (AWS Best Practice)
resource "aws_subnet" "tgw_subnets" {
  count             = 3
  vpc_id            = aws_vpc.workload.id
  cidr_block        = cidrsubnet(aws_vpc.workload.cidr_block, 12, count.index) # /28
  availability_zone = data.aws_availability_zones.available.names[count.index]

  tags = { Name = "workload-tgw-attachment-az-${count.index}" }
}

# Attach Workload VPC to Shared TGW
resource "aws_ec2_transit_gateway_vpc_attachment" "workload_attach" {
  transit_gateway_id = data.aws_ec2_transit_gateway.shared.id
  vpc_id             = aws_vpc.workload.id
  subnet_ids         = aws_subnet.tgw_subnets[*].id

  tags = { Name = "workload-to-tgw-attachment" }
}

# Route all outbound internet traffic from private subnets to TGW
resource "aws_route" "private_to_tgw_egress" {
  route_table_id         = aws_route_table.private.id
  destination_cidr_block = "0.0.0.0/0"
  transit_gateway_id     = data.aws_ec2_transit_gateway.shared.id
}

๐Ÿงญ Step-by-Step Operational Playbook: Rolling Out a Centralized TGW Hub-and-Spoke Network

Follow this step-by-step runbook to connect Spoke VPCs through a central Transit Gateway and Inspection Firewall VPC without causing asymmetric routing blackholes:

Step 1: Create the Transit Gateway in the Network Hub Account

  1. Plain-English Goal: Disable DefaultRouteTableAssociation and DefaultRouteTablePropagation so development VPCs cannot accidentally talk to production VPCs by default.
  2. Action:
    aws ec2 create-transit-gateway \
      --description "Enterprise-Core-TGW" \
      --options AmazonSideAsn=64512,AutoAcceptSharedAttachments=enable,DefaultRouteTableAssociation=disable,DefaultRouteTablePropagation=disable

Step 2: Share the TGW Across Accounts via AWS RAM

  1. Plain-English Goal: Allow spoke workload accounts to attach their VPCs to the central TGW without owning the TGW itself.
  2. Action:
    aws ram create-resource-share \
      --name "Core-TGW-Share" \
      --resource-arns "arn:aws:ec2:us-east-1:111122223333:transit-gateway/tgw-0abc12345" \
      --principals "arn:aws:organizations::111122223333:organization/o-exampleorgid"

Step 3: Attach the Inspection VPC with ApplianceModeSupport=enable

  1. Plain-English Goal: Ensure both directions of a TCP conversation (SYN and SYN-ACK) pass through the same Availability Zone firewall appliance so stateful inspection never drops return packets.
  2. Action:
    aws ec2 modify-transit-gateway-vpc-attachment \
      --transit-gateway-attachment-id tgw-attach-inspection123 \
      --options ApplianceModeSupport=enable

Step 4: Configure Segregated TGW Route Tables (Spoke-RT vs Firewall-RT)

  1. Plain-English Goal: Force all spoke traffic (0.0.0.0/0) into the Inspection VPC first, and let the Inspection VPC route table forward clean traffic onward to the destination spoke or NAT Gateway.
  2. Action:
    # Route all traffic entering from Spoke VPCs to the Inspection Firewall Attachment
    aws ec2 create-transit-gateway-route \
      --destination-cidr-block 0.0.0.0/0 \
      --transit-gateway-route-table-id tgw-rtb-spokes \
      --transit-gateway-attachment-id tgw-attach-inspection123

Step 5: Verify End-to-End Packet Flow & Free S3 Gateway Endpoint Bypass

  1. Plain-English Goal: Confirm internet traffic routes via the Hub NAT Gateway while S3 traffic uses the free Gateway Endpoint directly.
  2. Action:
    # Inside a Spoke VPC Pod/EC2:
    traceroute -n -T -p 443 8.8.8.8
    aws ec2 describe-prefix-lists --filters "Name=prefix-list-name,Values=com.amazonaws.us-east-1.s3"

๐Ÿ› ๏ธ Real-World Troubleshooting & Failure Modes

1. Asymmetric Routing & The Blackhole Trap

  • Symptom: Workload instances can send packets out through the Hub NAT Gateway, but return packets never arrive.
  • Root Cause: Traffic was routed from Spoke โ†’ TGW โ†’ Hub, but the Hub Route Table forgot to add a route back to the Spoke CIDR (10.1.0.0/16 โ†’ tgw-attach-dev). The NAT Gateway received the response from the internet, but had no route back to Spoke VPC Dev, blackholing the packet!
  • Fix: Ensure route propagation is enabled between Spoke attachments and the Hub Route Table.

2. Missing Dedicated /28 Subnets

  • Symptom: When associating a VPC with TGW, AWS creates Elastic Network Interfaces (ENIs). If an engineer attaches TGW using general application subnets, NACLs or IP exhaustion in those subnets break the entire cross-account network bridge.
  • Fix: Always create small, isolated /28 subnets specifically dedicated to the TGW attachment in every AZ.

๐Ÿ“ Knowledge Check & Real-World Interview Scenarios

โ“ Question 1: The Dev-to-Prod Cross-Contamination Incident

During an audit, security flags that an engineer in the Dev Account was able to connect to a PostgreSQL database in the Production Account over private IPs. Both accounts are attached to the same Transit Gateway.

How did this happen, and how do you configure Transit Gateway Route Tables to enforce complete network air-gapping between Dev and Prod?

โœ… Answer & Explanation

Why it Happened (Default TGW Route Table Anti-Pattern): When the Transit Gateway was created, default_route_table_association: enable and default_route_table_propagation: enable were left on. This places all VPC attachments into a single giant flat routing table. Every VPC attachment propagates its routes to all others, acting like an open router where any Spoke can route to any other Spoke.

How to Air-Gap Dev and Prod:

  1. Disable Default Route Tables: Set default_route_table_association = "disable" and default_route_table_propagation = "disable".
  2. Implement Multi-Route-Table Segmentation (VRF):
    • Create a Dev-TGW-Route-Table associated with Dev VPCs.
    • Create a Prod-TGW-Route-Table associated with Prod VPCs.
    • In the Dev-TGW-Route-Table, route 0.0.0.0/0 to the Central Egress Hub, but DO NOT add or propagate the Production CIDR (10.2.0.0/16).
    • If a Dev packet attempts to route to 10.2.0.0/16, the TGW drops the packet at Layer 3 with zero possible routing path!

โ“ Question 2: Transit Gateway Crossover Cost Math

A FinOps consultant points out that while Centralized NAT Gateways eliminate redundant monthly base fees, AWS Transit Gateway charges $0.02 per Gigabyte for all data processed across attachments.

At what monthly outbound data transfer volume does Centralized Egress become MORE expensive than giving each account its own dedicated NAT Gateway?

โœ… Answer & Explanation

The Mathematical Equation: Let N be the number of standalone NAT Gateways eliminated (e.g. 100 NAT Gateways across accounts).

  • Fixed savings on NAT base fees: 100 ร— $32.85 = $3,285/month.
  • Extra TGW data processing cost: $0.02 ร— X GB.

To find the breakeven data volume (X): ๐Ÿ“ 0.02 ร— X =3,285 โŸน X = 3285 / 0.02 = 164,250 GB (approx. 164 Terabytes/month!)

Architectural Conclusion:

  • For the vast majority of enterprise microservice architectures processing under 100 Terabytes of outbound internet traffic per month, Centralized TGW Egress saves massive amounts of money.
  • Only extreme high-volume streaming, video processing, or petabyte-scale data ingestion workloads justify dedicated local NAT Gateways to bypass TGW data processing charges!

Real-Time Terraform Central Egress Route Configuration

# Route all outbound 0.0.0.0/0 internet traffic from spoke VPC to Central Egress Transit Gateway
resource "aws_route" "spoke_to_central_tgw" {
  route_table_id         = aws_route_table.spoke_private.id
  destination_cidr_block = "0.0.0.0/0"
  transit_gateway_id     = aws_ec2_transit_gateway.enterprise_hub.id
}

resource "aws_ec2_transit_gateway_vpc_attachment" "spoke_attachment" {
  transit_gateway_id = aws_ec2_transit_gateway.enterprise_hub.id
  vpc_id             = aws_vpc.spoke_workload.id
  subnet_ids         = aws_subnet.spoke_tgw_attachment[*].id

  tags = {
    Name = "spoke-workload-tgw-attachment"
  }
}

โ“ Question 3: The Asymmetric Out-of-State Firewall Outage in Multi-AZ Transit Gateway

Your security operations center (SOC) reports that after deploying Palo Alto firewalls behind a Gateway Load Balancer in the central inspection VPC, approximately 50% of outbound connections from spoke workloads hang indefinitely. Firewall syslog shows thousands of TCP: Out-of-state packet dropped / non-SYN packet rejected errors.

As the Lead Network Architect, diagnose the root cause and provide the exact AWS Transit Gateway configuration setting required to fix this.

โœ… Answer & Explanation

Root Cause Analysis:

  • Stateful next-generation firewalls track the full TCP state machine (SYN -> SYN-ACK -> ACK).
  • By default, AWS Transit Gateway uses multi-AZ equal-cost multi-path (ECMP) routing without maintaining state affinity.
  • An outbound request originated in us-east-1a is routed to the firewall in us-east-1a. When the remote server responds, the return packet arrives at the TGW, which hashes the return flow independently and delivers it to the firewall in us-east-1b.
  • Firewall 1b has never seen the initial SYN packet and has no state table entry for that connection tuple. By design, it rejects the SYN-ACK as an out-of-state packet.

The Architectural Solution:

  • Enable TGW Appliance Mode on the Hub VPC attachment:
    aws ec2 modify-transit-gateway-vpc-attachment \
      --transit-gateway-attachment-id <hub-attachment-id> \
      --options ApplianceModeSupport=enable
  • Appliance Mode forces Transit Gateway to choose the ENI symmetrically, guaranteeing that all inbound and outbound packets belonging to the same flow are directed to the same Availability Zone throughout the connection lifespan.