AWS Builder Center
Why "Just Add a NAT Gateway" Is the Most Expensive VPC Mistake on AWS (and How to Architect Around It)

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.

programmer and devops
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:
  1. Place application workloads (Amazon ECS tasks, EKS pods, EC2 instances, and VPC-attached AWS Lambda functions) inside Private Subnets.
  1. Place one Managed NAT Gateway inside each Availability Zone's Public Subnet.
  1. 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/month  in pure NAT Gateway processing fees—simply because  s3.us-east-1.amazonaws.com  resolves to a public IPv4 address matched by  0.0.0.0/0 .
AWS VPC Egress Architecture: Default NAT Hairpin vs. Endpoint-Optimized Routing




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 20
Cross-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:
  1. 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 named  prod-<region>-starport-layer-bucket !).
  1. Amazon DynamoDB ( dynamodb.<region>.amazonaws.com ) — high-throughput key-value reads/writes.
  1. 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 than  0.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:
  1. The initial authentication and manifest lookup (~few KB) hit  api.ecr.<region>.amazonaws.com  and  dkr.ecr.<region>.amazonaws.com .
  1. ECR responds with an HTTP  307 Temporary Redirect  pointing 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 allow  s3:GetObject  on  arn:aws:s3:::prod-${var.aws_region}-starport-layer-bucket/* —otherwise container image pulls from Amazon ECR in private subnets will fail with  403 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 × G
Interface 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
The 206 GB Break-Even Rule: Managed NAT Gateway vs. Interface VPC Endpoint

  • If a service processes  < 206 GB / AZ / month  (e.g., occasional  Secrets Manager  or  SSM Parameter Store  calls), 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 for  logs.<region>.amazonaws.com  in high-throughput microservices or  kinesis ), provisioning an Interface VPC Endpoint pays for itself immediately and cuts every additional gigabyte's cost by 77.8% ( $0.01/GB  vs.  $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/GB  NAT 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

  1. Always provision S3 and DynamoDB Gateway Endpoints on Day 1—they cost  $0.00/hour  and  $0.00/GB , require zero application code changes, and offload S3, DynamoDB, and ECR layer downloads from NAT Gateways.
  1. 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.
  1. 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.
  1. 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/month  per environment for 3-AZ redundancy.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article