
Why "Just Add a NAT Gateway" Is the Most Expensive VPC Mistake on AWS (and How to Architect Around It)
A practical engineering guide to AWS NAT Gateway billing mechanics, VPC Flow Log diagnostics, free Gateway VPC Endpoints for S3, DynamoDB, and ECR, the 206 GB PrivateLink break-even rule, and Dual-Stack IPv6 egress.
When provisioning a production VPC on AWS, almost every starter template—whether in Terraform (
terraform-aws-modules/vpc/aws ), AWS CDK ( ec2.Vpc ), or CloudFormation—defaults to the same network topology:- Place application workloads (Amazon ECS tasks, EKS pods, EC2 instances, and VPC-attached AWS Lambda functions) inside Private Subnets.
- Place one Managed NAT Gateway inside each Availability Zone's Public Subnet.
- Add a single catch-all route (
0.0.0.0/0 -> nat-xxxxxxxx) to every Private Route Table.
From a security standpoint, this works as intended: private workloads have no public IPv4 addresses and cannot receive unsolicited inbound traffic from the internet.
From a FinOps and network engineering standpoint, however, a catch-all NAT Gateway route without endpoint routing is one of the most common causes of bill shock on AWS. Worse, the majority of the traffic paying the NAT Gateway tax isn't even going to the public internet—it's going to AWS services in the exact same region.
1. The Anatomy of a NAT Gateway Bill
Managed NAT Gateway pricing in
us-east-1 (and most core regions) has two components:Billing Dimension | Rate ( us-east-1 ) | 3-AZ Production Baseline |
|---|---|---|
Hourly Availability Charge | $0.045 / hour per NAT Gateway | 3 x $0.045 x 730 hrs = $98.55 / month |
Data Processing Charge | $0.045 / GB processed | $45.00 per TB (regardless of destination!) |
The hourly charge (
~$98.55/month for three Availability Zones) is predictable. The Data Processing Charge ( $0.045/GB ) is where budgets quietly implode:- Every byte traversing the NAT Gateway—whether outbound (
SYN/upload) or inbound (ACK/download response)—is metered at$0.045/GB.
- If your private ECS tasks or EKS nodes pull 2 TB of container images from Amazon ECR, read/write 7 TB of Parquet/JSON objects in Amazon S3, and exchange 2 TB of items with Amazon DynamoDB each month, that 11 TB of internal AWS traffic costs
$495.00/monthin pure NAT Gateway processing fees—simply becauses3.us-east-1.amazonaws.comresolves to a public IPv4 address matched by0.0.0.0/0.

2. Step 1: Catching the Culprits with VPC Flow Logs & CloudWatch Insights
Before changing route tables, identify which destination IPs are responsible for your NAT Gateway byte volume. Enable VPC Flow Logs on the NAT Gateway's Elastic Network Interface (
eni-xxxxxxxx ) and run this CloudWatch Logs Insights query:fields pktSrcAddr, pktDstAddr, bytes| filter dstPort = 443| stats sum(bytes) / 1073741824 as Total_GB by pktDstAddr| sort Total_GB desc| limit 20Cross-referencing the top
pktDstAddr IPs against AWS's published ip-ranges.json almost always reveals the same three culprits accounting for 75%–90% of NAT traffic:- Amazon S3 (
s3.<region>.amazonaws.com) — artifacts, backups, data lake reads/writes, and Amazon ECR Docker image layers (which are stored in an AWS-managed S3 bucket namedprod-<region>-starport-layer-bucket!).
- Amazon DynamoDB (
dynamodb.<region>.amazonaws.com) — high-throughput key-value reads/writes.
- Telemetry & Control-Plane APIs — Amazon CloudWatch Logs (
logs.<region>.amazonaws.com), Amazon ECR API/DKR, AWS Secrets Manager, and Amazon SQS.
3. Fix #1: Eliminate 80%+ of NAT Traffic Instantly with Free Gateway VPC Endpoints
AWS provides two distinct types of VPC Endpoints, and confusing their pricing models leads many teams to skip them altogether:
- Gateway VPC Endpoints (supported only for Amazon S3 and Amazon DynamoDB):
- Hourly cost:
$0.00
- Data processing cost:
$0.00 / GB
- Mechanism: Injects an AWS-managed Prefix List (
pl-xxxxxxxx) directly into your Private Route Tables. Because a prefix list is more specific than0.0.0.0/0(longest-prefix match), all S3 and DynamoDB traffic bypasses the NAT Gateway automatically.
- Interface VPC Endpoints (powered by AWS PrivateLink, supporting 100+ AWS services):
- Hourly cost:
$0.01 / hour per AZ(~$7.20 / month / AZ)
- Data processing cost:
$0.01 / GB(still 78% cheaper per GB than NAT Gateway's$0.045/GB).
The Hidden Bonus: S3 Gateway Endpoints Make ECR Image Pulls Nearly Free
When an EKS node or ECS task pulls a 1.5 GB container image from Amazon ECR:
- The initial authentication and manifest lookup (~few KB) hit
api.ecr.<region>.amazonaws.comanddkr.ecr.<region>.amazonaws.com.
- ECR responds with an HTTP
307 Temporary Redirectpointing to Amazon S3 (prod-<region>-starport-layer-bucket), where the actual multi-hundred-megabyte compressed image layers live.
That means provisioning a free S3 Gateway VPC Endpoint automatically offloads ~99% of your Amazon ECR image pull bandwidth from your NAT Gateway at zero cost.
Production Terraform Configuration
# 1. Free Gateway VPC Endpoint for Amazon S3 (Zero hourly or per-GB fee)resource "aws_vpc_endpoint" "s3_gateway" { vpc_id = aws_vpc.main.id service_name = "com.amazonaws.${var.aws_region}.s3" vpc_endpoint_type = "Gateway" route_table_ids = aws_route_table.private[*].id
tags = { Name = "${var.env}-s3-gateway-vpce" }}
# 2. Free Gateway VPC Endpoint for Amazon DynamoDB (Zero hourly or per-GB fee)resource "aws_vpc_endpoint" "dynamodb_gateway" { vpc_id = aws_vpc.main.id service_name = "com.amazonaws.${var.aws_region}.dynamodb" vpc_endpoint_type = "Gateway" route_table_ids = aws_route_table.private[*].id
tags = { Name = "${var.env}-dynamodb-gateway-vpce" }}Security Tip: If you restrict your S3 Gateway Endpoint with a custom Endpoint Policy (policy), remember to allows3:GetObjectonarn:aws:s3:::prod-${var.aws_region}-starport-layer-bucket/*—otherwise container image pulls from Amazon ECR in private subnets will fail with403 Access Denied.
4. Fix #2: The 206 GB Break-Even Rule for Interface VPC Endpoints
What about services that don't support Gateway Endpoints, such as CloudWatch Logs, Secrets Manager, SQS, or Kinesis? Should you create Interface Endpoints (PrivateLink) for them or let them traverse the NAT Gateway?
We can solve this with a straightforward break-even calculation per Availability Zone (
G = monthly GB processed in one AZ):NAT Gateway Processing Cost (G) = $0.045 × GInterface Endpoint Cost (G) = $7.20/month + ($0.010 × G)
Break-Even Threshold:$0.045 × G = $7.20 + ($0.010 × G)$0.035 × G = $7.20 ===> G = 205.7 GB / AZ / month
- If a service processes
< 206 GB / AZ / month(e.g., occasionalSecrets ManagerorSSM Parameter Storecalls), keep routing it through your existing NAT Gateway (unless compliance mandates zero internet-bound paths).
- If a service processes
> 206 GB / AZ / month(very common forlogs.<region>.amazonaws.comin high-throughput microservices orkinesis), provisioning an Interface VPC Endpoint pays for itself immediately and cuts every additional gigabyte's cost by 77.8% ($0.01/GBvs.$0.045/GB).
5. Fix #3: Offloading Public Package Repositories with Dual-Stack IPv6 and Egress-Only IGW
Once AWS internal traffic is routed through Gateway and Interface Endpoints, what remains on the NAT Gateway? Typically:
- OS and language package updates (
apt,apk,npm,pypi,crates.io, GitHub releases)
- Outbound webhooks and third-party SaaS APIs (Stripe, Slack, Datadog, OpenAI)
Most modern CDNs, package registries (Debian/Ubuntu, Alpine, npm, PyPI, Cloudflare, Fastly), and public APIs support IPv6. In AWS VPC:
- An Egress-Only Internet Gateway (
aws_egress_only_internet_gateway) provides outbound-only NAT-like statefulness for IPv6 traffic from private subnets.
- Hourly cost:
$0.00
- Data processing fee:
$0.00 / GB(you only pay standard EC2 internet data transfer out rates, avoiding the$0.045/GBNAT Gateway processing surcharge entirely).
resource "aws_egress_only_internet_gateway" "ipv6_egress" { vpc_id = aws_vpc.main.id}
resource "aws_route" "private_ipv6_egress" { count = length(aws_route_table.private) route_table_id = aws_route_table.private[count.index].id destination_ipv6_cidr_block = "::/0" egress_only_gateway_id = aws_egress_only_internet_gateway.ipv6_egress.id}By enabling Dual-Stack (
IPv4 + IPv6 ) on your private subnets, OS package downloads and dual-stack API calls automatically prefer IPv6 ( ::/0 -> eigw-xxxx ), leaving your IPv4 NAT Gateway exclusively for legacy IPv4-only third-party endpoints.
6. Putting It All Together: Real-World Monthly Cost Impact
Consider a typical 3-AZ production cluster processing 7 TB S3, 2 TB DynamoDB, 2 TB ECR, 1 TB CloudWatch Logs, and 1 TB third-party APIs per month:
Traffic Source (Monthly) | Default NAT Hairpin ( 0.0.0.0/0 -> NAT ) | Optimized VPC Routing Architecture |
|---|---|---|
3x NAT Gateway Hourly Base | $98.55 | $98.55 (or $32.85 with 1 NAT in non-prod) |
Amazon S3 (7,000 GB) | $315.00 ( $0.045/GB ) | $0.00 (S3 Gateway Endpoint) |
Amazon DynamoDB (2,000 GB) | $90.00 ( $0.045/GB ) | $0.00 (DynamoDB Gateway Endpoint) |
Amazon ECR Image Pulls (2,000 GB) | $90.00 ( $0.045/GB ) | $0.90 (99% S3 Gateway + 20 GB metadata) |
CloudWatch Logs (1,000 GB) | $45.00 ( $0.045/GB ) | $31.60 (3-AZ Interface Endpoint + $0.01/GB ) |
External APIs & Packages (1,000 GB) | $45.00 ( $0.045/GB ) | $11.25 (75% via IPv6 EIGW, 250 GB via NAT) |
Total Monthly Egress Overhead | $683.55 / month | $142.30 / month (-79.2%) |
Summary Checklist for Every AWS VPC
- Always provision S3 and DynamoDB Gateway Endpoints on Day 1—they cost
$0.00/hourand$0.00/GB, require zero application code changes, and offload S3, DynamoDB, and ECR layer downloads from NAT Gateways.
- Apply the 206 GB/AZ/month Rule before creating PrivateLink Interface Endpoints—use VPC Flow Logs to verify which AWS APIs exceed the break-even threshold.
- Enable Dual-Stack IPv6 + Egress-Only Internet Gateways in private subnets so high-volume package pulls and CDN traffic bypass IPv4 NAT processing charges completely.
- Right-size non-production NAT topology—use a single NAT Gateway (or lightweight NAT instance / IPv6 EIGW) in ephemeral dev/staging VPCs rather than paying
$98.55/monthper environment for 3-AZ redundancy.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article