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.
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 / Dimension | Component | Technical Behavior |
|---|---|---|
| Hop 1 | Private EC2 (10.0.2.15) | Initiates outbound HTTPS (TCP:443) for OS package updates or third-party APIs. |
| Hop 2 | Private Route Table | Matches 0.0.0.0/0 -> nat-gateway in the same Availability Zone for HA. |
| Hop 3 | NAT Gateway (Public Subnet) | Performs SNAT: replaces source 10.0.2.15 with the NAT Elastic IP (e.g., 54.210.x.x). |
| Hop 4 | Internet Gateway → Internet | Forwards 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.