How is a NAT gateway billed, and why do data processing charges dominate?
A NAT gateway has two charges. The first is an hourly fee for each gateway that exists, whether or not it carries traffic. The second is a per-GB data processing charge on every byte that passes through it, in either direction. Responses count as well as requests, so a container image pull or an S3 download is charged on the inbound bytes, not just the small outbound request.
The processing charge is added to normal data transfer charges. Traffic to the internet still pays internet egress rates. Traffic that crosses Availability Zones to reach a NAT gateway in another AZ still pays cross-AZ transfer. Traffic to an AWS service in the same region may have no transfer charge of its own, but it still pays the NAT processing fee if it goes through the gateway.
That last case is usually the largest. Workloads in private subnets talk to AWS service APIs all the time: S3 for artifacts and data, DynamoDB, ECR for image layers, CloudWatch Logs for log shipping, STS for credentials, and Secrets Manager for configuration. Without VPC endpoints, all of this goes through the NAT gateway. A cluster that pulls large images on every scale-out event, or a batch job reading terabytes from S3, can produce far more NAT bytes than any real internet traffic.
Rates differ by region and change over time, so check the AWS pricing page for your regions rather than relying on remembered figures.
This matters most for teams running private subnets whose NAT gateway line item is large or growing faster than their user-facing traffic.
Who should use it?
VPC endpoints for NAT cost reduction are worth the effort if your workloads run in private subnets, reach AWS services through a NAT gateway, and move meaningful volume to those services. Typical cases:
- Container platforms (EKS, ECS, or self-managed Kubernetes on EC2) that pull images from ECR on deploys, node replacement and autoscaling.
- Data and batch workloads such as ETL jobs, analytics clusters and ML training that read from or write to S3 or DynamoDB in the same region.
- Log-heavy services that ship large volumes to CloudWatch Logs from private subnets.
- Platform and FinOps engineers who own shared VPC design across many accounts and need a repeatable pattern, not a one-off fix.
- Security and compliance teams that need private-only subnets with no internet path, or want to restrict S3 access to requests that arrive through known endpoints.
It matters less if most of your NAT bytes go to third-party destinations. Endpoints can't change those, so look at the alternatives section instead. It also matters less if your workloads run in public subnets with public IPs, which don't use a NAT gateway at all, or if NAT spend is already small compared with the engineering time needed to change routing. Gateway endpoints for S3 and DynamoDB are free, so almost any VPC with private subnets should have them. Interface endpoints need the break-even check described later.
Which traffic is driving your NAT gateway bytes?
Start with billing data, because it shows whether the growth is in hours or in bytes. In Cost Explorer, filter on the EC2 service and group by usage type. NAT gateway charges appear as region-prefixed usage types ending in NatGateway-Hours and NatGateway-Bytes. If hours are flat and bytes are climbing, more gateways won't explain the growth; the cause is traffic volume. The Cost and Usage Report gives the same split per resource ID, so you can tell which gateway, and therefore which VPC and workload, is responsible.
Bytes alone don't show where the traffic goes. Enable VPC Flow Logs on the NAT gateway's elastic network interface and send them to CloudWatch Logs or S3. The example query filters records whose source address falls inside your VPC CIDR, which counts each flow once, before translation. It sums bytes grouped by destination address and sorts the results descending. Run it over a representative window such as a full business week, so batch jobs and deploys are included.
Next, map the top destination IPs against AWS's published IP ranges and sort them into two groups:
- Must cross NAT: third-party APIs, public package registries, and external SaaS. Endpoints can't reduce these costs. The alternatives section at the end of this article covers the options for this group.
- Uses NAT only to reach AWS: S3, DynamoDB, ECR, CloudWatch, STS and similar public service endpoints. This traffic leaves the VPC only because no private path exists. In most accounts it accounts for most of the NAT gateway bytes.
filter isIpv4InSubnet(srcAddr, "10.0.0.0/16")
and srcAddr != "10.0.0.220"
and not isIpv4InSubnet(dstAddr, "10.0.0.0/16")
| stats sum(bytes) as bytesTransferred by dstAddr
| sort bytesTransferred desc
| limit 25
A CloudWatch Logs Insights query over NAT gateway ENI flow logs that sums bytes by destination IP for VPC-originated traffic, giving a ranked list to match against AWS's published IP ranges.
How does it work? Gateway and interface VPC endpoints
The cost reduction comes from routing, not from a discount. Traffic to AWS services stops using the 0.0.0.0/0 route to the NAT gateway and takes a private path inside the AWS network, so the NAT gateway never processes those bytes and never bills for them. Endpoints give that traffic a private path, but the two types do it in different ways.
NAT path: instance -> NAT gateway (hourly + per GB) -> IGW -> public service endpoint
Gateway endpt: instance -> route table: prefix list -> vpce-gw -> S3 / DynamoDB (no charge)
Interface endpt: instance -> private DNS -> ENI in own AZ (hourly + per GB) -> service via PrivateLink
A gateway endpoint adds a route to the route tables you choose. The destination is an AWS-managed prefix list that covers the service's IP ranges. Packets to S3 or DynamoDB match that more specific route before the 0.0.0.0/0 NAT route, so they never reach the NAT gateway. There is no hourly charge and no per-GB charge. A gateway endpoint only reaches resources in the same region. Cross-region bucket traffic still goes through NAT.
An interface endpoint uses PrivateLink. It places an ENI in a subnet in each AZ you enable. With private DNS turned on, the public service hostname (for example the STS or ECR hostname) resolves to those ENI addresses inside the VPC, so SDKs work without config changes. Each service needs its own endpoint, and you pay an hourly charge for each AZ it covers, plus a per-GB processing charge of its own.
| Gateway endpoint | Interface endpoint | |
|---|---|---|
| Services | S3, DynamoDB | Most AWS services |
| Mechanism | Prefix-list route | ENI + private DNS |
| Hourly charge | None | Per AZ |
| Per-GB charge | None | Yes |
| Scope | Same region | Same region, extendable via peering/TGW |
ECR combines both types. Image manifests come from the ECR API and Docker registry endpoints, but the image layers are stored in S3. A private pull therefore needs the ecr.api and ecr.dkr interface endpoints plus the S3 gateway endpoint. If the S3 gateway endpoint is missing, the layer bytes, which make up most of the pull, still go through NAT.
+--------------- VPC (region A) ---------------+
| |
| +----------+ (1) 0.0.0.0/0 route |
| | instance |-------> [ NAT gateway ]-----------> IGW --> public endpoint
| | private | hourly + per GB |
| | subnet | (2) prefix-list route |
| | AZ-a |-------> [ GW endpoint ]-----------> S3 / DynamoDB
| | | no charge | (same region only)
| | | (3) private DNS -> ENI |
| | |-------> [ ENI (AZ-a) ]-----------> PrivateLink -> STS, ECR
| +----------+ hourly per AZ + per GB |
| |
+----------------------------------------------+
ECR private pull: manifests via ecr.api + ecr.dkr (path 3),
image layers from S3 (path 2).
Traffic leaves a private subnet by one of three routes: the default route through the NAT gateway, a prefix-list route to a free same-region S3/DynamoDB gateway endpoint, or private DNS to a per-AZ interface endpoint ENI. A private ECR pull needs both endpoint types.
How to implement VPC endpoints for S3, DynamoDB and ECR
Roll out in order of cost and risk, cheapest first.
1. Gateway endpoints for S3 and DynamoDB. They have no hourly or per-GB charge, so add them without a business case. Associate each one with every private subnet's route table. A missed table keeps sending its traffic through the NAT. The association adds a route to the service's managed prefix list, which is more specific than 0.0.0.0/0, so matching traffic bypasses the NAT. Gateway endpoints only cover same-region buckets and tables.
2. Interface endpoints for high-volume services. Next, add ecr.api, ecr.dkr and logs. Enable private DNS so the default SDK hostnames resolve to the endpoint ENIs, which means no application changes. Attach a security group that allows 443 from the VPC CIDR. The accompanying example creates the S3 gateway endpoint and one interface endpoint.
3. Policies. Scope each endpoint policy to the buckets and repositories you own. Add S3 bucket policies that deny access unless aws:SourceVpce or aws:SourceVpc matches. This turns the endpoints into an exfiltration control: stolen credentials used outside your network fail. Exempt break-glass and CI roles first, or you will lock out administrators.
4. Verify. Check that each route table shows the prefix-list route. Filter VPC flow logs on the NAT gateway's ENI and confirm that S3 and ECR destinations no longer appear. Over the following days, watch the NatGateway-Bytes usage type fall in Cost Explorer.
This check is repeatable, so you no longer need to re-investigate the bill each month. One dashboard shows whether the routing still holds.
#!/usr/bin/env bash
set -euo pipefail
REGION="us-east-1"
VPC_ID="vpc-0abc1234def567890"
PRIVATE_RTBS="rtb-0aaa1111bbbb2222c rtb-0ddd3333eeee4444f"
PRIVATE_SUBNETS="subnet-0123abcd4567ef890 subnet-0fed9876cba54321a"
ENDPOINT_SG="sg-0a1b2c3d4e5f67890" # allows TCP 443 from the VPC CIDR
aws ec2 create-vpc-endpoint \
--region "$REGION" \
--vpc-id "$VPC_ID" \
--vpc-endpoint-type Gateway \
--service-name "com.amazonaws.${REGION}.s3" \
--route-table-ids $PRIVATE_RTBS
aws ec2 create-vpc-endpoint \
--region "$REGION" \
--vpc-id "$VPC_ID" \
--vpc-endpoint-type Interface \
--service-name "com.amazonaws.${REGION}.ecr.dkr" \
--subnet-ids $PRIVATE_SUBNETS \
--security-group-ids "$ENDPOINT_SG" \
--private-dns-enabled
aws ec2 describe-route-tables \
--region "$REGION" \
--route-table-ids $PRIVATE_RTBS \
--query 'RouteTables[].{Table:RouteTableId,Endpoints:Routes[?DestinationPrefixListId].GatewayId}'
AWS CLI commands that create an S3 gateway endpoint on every private route table and an ECR Docker registry interface endpoint with private DNS, then check that the prefix-list routes are present.
How can it save engineering time?
The direct saving is money, but a well-run endpoint rollout also removes recurring work.
- Fewer cost investigations. Without endpoints, every new data pipeline or larger container image can show up as an unexplained jump in
NatGateway-Bytes, and someone has to trace it through flow logs. Once AWS service traffic takes the endpoint path, NAT bytes mostly reflect real third-party egress. Anomalies become smaller and easier to attribute. - Define once, reuse everywhere. Put the gateway endpoints, interface endpoints, security group and route table associations in your infrastructure-as-code VPC module. Every new VPC then gets the correct routing by default, instead of each team finding the NAT charge after its first big bill.
- Fewer NAT-related incidents. A NAT gateway limits simultaneous connections to a single destination and reports failures through the
ErrorPortAllocationCloudWatch metric. High-concurrency S3 or ECR traffic is a common way to hit that limit. Moving it to a gateway endpoint takes it off the NAT entirely, which removes a class of intermittent connection errors that are slow to debug. - Simpler security reviews. Endpoint policies and
aws:SourceVpcebucket conditions give reviewers one clear control to check: data access only from known network paths. That replaces case-by-case arguments about whether a bucket is reachable from the internet. - A repeatable verification step. The route table query and the flow log query above can run as a scheduled check or a CI step for network changes. Drift, such as a new route table that nobody associated with the S3 endpoint, is found automatically rather than at month-end.
The time cost sits up front: identifying traffic, testing policies against every access path, and updating the shared VPC module. After that, maintenance is mostly adding an interface endpoint when a new high-volume service passes break-even.
When does an interface endpoint pay for itself?
Every interface endpoint carries a fixed hourly charge for each AZ it is deployed in, whether or not traffic flows. The per-GB savings only appear once traffic volume covers that fixed cost.
Illustrative estimate. Every rate below is a placeholder. Substitute current pricing for your region before acting on the numbers.
- Endpoint hourly rate (H): $0.01 per AZ-hour
- NAT data processing rate (N): $0.045/GB
- Endpoint data processing rate (E): $0.01/GB
- AZs: 3, at 730 hours/month
- Fixed cost per endpoint: 0.01 × 3 × 730 = $21.90/month
| Service | Endpoints | Monthly GB | Cost via NAT | Cost via endpoint | Net monthly |
|---|---|---|---|---|---|
| S3 (interface) | 1 | 3,000 | $135.00 | $51.90 | saves $83.10 |
ECR (ecr.api + ecr.dkr) |
2 | 4,000 | $180.00 | $83.80 | saves $96.20 |
| STS | 1 | 5 | $0.23 | $21.95 | loses $21.72 |
The general break-even formula:
Break-even GB/month = (endpoints × AZs × 730 × H) ÷ (N − E)
With these inputs, a single endpoint breaks even at about 626 GB/month. STS is called constantly, but each response is a few kilobytes. It would need thousands of times more traffic to cover its hourly cost.
ECR has a complication. Image layers are downloaded from S3, so the S3 gateway endpoint carries most of the pull bytes. Before counting traffic toward the ECR endpoints, measure what actually crosses the NAT for each hostname.
For a service below break-even, deploy its endpoint only when you need it for reasons other than cost, such as private-only subnets or compliance.
When should you avoid VPC endpoints or centralised designs?
Endpoints add their own cost and their own failure modes. Check each of the following before you roll them out widely.
Interface endpoint hours multiply. Each interface endpoint is billed per hour in every AZ where it has an ENI. A single service across three AZs means three billable attachments. Ten services across three AZs in twenty VPCs means 600. A centralised endpoint VPC reduces that count, but cross-VPC traffic then pays transit or peering charges, which can cancel out the savings for high-volume services.
Gateway endpoints are regional. An S3 gateway endpoint serves only buckets in the same region. Requests to a bucket in another region still leave through the NAT and incur processing and inter-region transfer charges, even though the route table looks correct.
Policies fail quietly. A bucket policy that denies any request not arriving via aws:SourceVpce also blocks the console, CI runners outside the VPC, and cross-account readers. These failures appear as access-denied errors in another team's pipeline days later. Scope the deny conditions narrowly and test every access path before you enforce them.
DNS bypass keeps NAT in the path. An interface endpoint only helps clients that resolve the service hostname through the VPC resolver. A client that uses a public resolver or a hardcoded regional URL gets public IPs and keeps paying the NAT.
Removing NAT exposes hidden dependencies. Package installs at boot, licence checks, and third-party telemetry all fail once the NAT is gone. Before you delete it, review a few weeks of flow logs and list every external destination.
What are the alternatives for cutting NAT and AWS egress costs?
Every option trades hourly fixed cost against per-GB charges and operational risk. The right choice depends on where your bytes go, not on which design is most common.
Per-AZ NAT gateways and endpoints. Each Availability Zone (AZ) routes through its own NAT gateway, and interface endpoints have an ENI in every AZ. Traffic never crosses an AZ boundary to reach them, so you avoid inter-AZ transfer charges. One AZ failing does not take down egress for the others. The cost is multiplied hourly charges, and that adds up across many VPCs.
Single NAT gateway. This is the cheapest on hourly charges, which makes it reasonable for dev environments. It is also a single point of failure. Workloads in other AZs pay inter-AZ transfer on top of NAT processing for every byte they send through it.
Centralised interface endpoints. Endpoints live in a shared VPC and spokes reach them over Transit Gateway or peering. This spreads the hourly cost across many VPCs. In exchange, you pay Transit Gateway per-GB processing or cross-AZ peering transfer. You also need Route 53 Resolver rules or private hosted zones shared with the spokes so endpoint DNS names resolve.
Reducing the bytes themselves. Endpoints only remove NAT processing for AWS service traffic. True internet egress to third parties is still billed as data transfer out. For that traffic, these measures usually save more:
- caching responses
- mirroring package repositories and container images into the VPC
- compressing payloads
Illustrative estimate (assumed numbers, not a benchmark): use this formula to compare a central design against per-VPC endpoints.
Monthly cost = (endpoint hours × hourly rate) + (GB × per-GB rate) + (cross-AZ or TGW GB × transfer rate)
Plug in your own rates and the volumes you measured from flow logs.
| Option | Hourly cost | Per-GB overhead | Resilience | Complexity |
|---|---|---|---|---|
| Per-AZ NAT + endpoints | High | Lowest | High | Low |
| Single NAT gateway | Lowest | Inter-AZ added | Low | Low |
| Centralised endpoints | Shared | TGW/cross-AZ added | Medium–High | High (DNS) |
| Caching, mirrors, compression | Varies | Reduces bytes | Unchanged | Medium |
How OneEnv can help
Disclosure: OneEnv is the product behind this blog.
OneEnv (oneenv.io) is a workspace-based governance platform for the things services share — environment variables, database structure, API routes and validation rules. A change to a shared value is staged on a branch, reviewed once, and then every affected service explicitly approves or rejects it before it goes live, so you can see who a change touches before it ships instead of finding out in production.
Applied to nat gateway cost reduction, this is where it helps:
Saves time
- Every service that inherits a shared value is listed in one place, so nobody searches repos and chats to find out who is affected.
- One review per branch replaces coordinating each team separately; each service still keeps its own approve/reject.
- Reviewers see the exact diff and the list of affected services up front, so approval is a decision rather than an investigation.
Saves cost
- Fewer production incidents and rollbacks caused by a shared value, route or column changing under a consumer unannounced.
- Less duplicated configuration to maintain: one shared definition inherited by many services.
- Per-service approve/reject means a bad shared value can be refused where it would break something, before it is live.
- OneEnv has a free plan (1 workspace, unlimited services and members, full governance), so trying it costs nothing.
These are qualitative benefits, not measured results — how much you save depends on how many services share the value.
Want to try it? Start at oneenv.io.