VPC TRANSIT & FINOPS

AWS NAT Gateway Architecture: Private Subnet Egress, SNAT & S3 Cost Optimization

A classic AWS architecture mistake is placing a NAT Gateway inside a private subnet or forgetting to route S3 traffic through a Gateway VPC Endpoint. CloudTracer simulates real Source NAT (SNAT) translation and calculates your live NAT data processing cost.

Simulate NAT Gateway Routing → Try Live Packet Challenge #1

Where NAT Gateway Lives

Always deploy the NAT Gateway inside a PUBLIC subnet with an Elastic IP (EIP) and a route to the Internet Gateway.

Private Subnet Route Table

Point the private subnet default route (0.0.0.0/0) to the NAT Gateway ID (nat-*) — never directly to an IGW.

Save $0.045/GB with S3 Gateway Endpoints

Adding a free S3 Gateway Endpoint to the private route table bypasses the NAT Gateway completely for S3 transfers.

Private EC2 Outbound Packet Flow via NAT Gateway

Step / DimensionComponentTechnical Behavior
Hop 1Private EC2 (10.0.2.15)Initiates outbound HTTPS (TCP:443) for OS package updates or third-party APIs.
Hop 2Private Route TableMatches 0.0.0.0/0 -> nat-gateway in the same Availability Zone for HA.
Hop 3NAT Gateway (Public Subnet)Performs SNAT: replaces source 10.0.2.15 with the NAT Elastic IP (e.g., 54.210.x.x).
Hop 4Internet Gateway → InternetForwards translated packet to the internet and routes stateful return traffic back to 10.0.2.15.

Terraform: Multi-AZ Private Route + Free S3 Gateway Endpoint

resource "aws_vpc_endpoint" "s3" {
  vpc_id            = aws_vpc.main.id
  service_name      = "com.amazonaws.us-east-1.s3"
  vpc_endpoint_type = "Gateway"
  route_table_ids   = [aws_route_table.private.id]
}

Frequently Asked Questions

Should a NAT Gateway be placed in a public or private subnet?

A NAT Gateway must be placed in a public subnet (one with a 0.0.0.0/0 -> igw route) and assigned an Elastic IP. Your private subnet route table then points 0.0.0.0/0 to that NAT Gateway.

How do I reduce high AWS NAT Gateway data transfer bills?

Add free Gateway VPC Endpoints for Amazon S3 and DynamoDB to your private route tables so S3/DynamoDB traffic stays on the AWS private backbone instead of paying $0.045/GB through NAT Gateway.

How do you make NAT Gateways highly available for SAA-C03?

Deploy one NAT Gateway in each Availability Zone (in each AZ public subnet) and configure each AZ private route table to target its local AZ NAT Gateway.

More Interactive AWS Architecture Guides