How is a NAT gateway billed, and why does AWS-service traffic cost so much?

A managed NAT gateway has two charges. The first is an hourly charge for each gateway, billed whether or not traffic flows. Highly available designs typically run one gateway per Availability Zone, so this charge multiplies by the number of AZs. The second is a per-GB data processing charge on every byte the gateway handles. Request bytes going out and response bytes coming back both count.

The processing charge is why AWS-service traffic gets expensive. The gateway does not check where a packet is going. A GetObject call to S3 in the same region is processed and billed the same way as a call to an external API. A workload that pulls large objects from S3, ships logs, or pulls container images through NAT pays the processing rate on all of it.

The processing charge is also separate from data transfer charges. Internet egress and cross-AZ transfer are billed on top of it where they apply.

Illustrative estimate (assumed numbers, not a benchmark)

Monthly NAT cost = (gateways × hours × hourly rate) + (GB processed × per-GB rate)

Assume 3 gateways, 730 hours, $0.05/hour, 10,000 GB processed, and $0.05/GB:

  • Hourly charges: 3 × 730 × $0.05 = $109.50
  • Processing charges: 10,000 × $0.05 = $500.00

At these assumed volumes, processing costs several times more than the hourly charge. Rates vary by region and change over time, so check current regional pricing before using this formula.

This article is for backend and platform engineers whose workloads run in private subnets and reach AWS APIs through NAT.

Who should use VPC endpoints to reduce NAT costs?

This approach fits teams that meet most of these conditions:

  • Workloads run in private subnets and reach AWS services through a NAT gateway. Typical examples are EKS or ECS clusters, EC2 fleets, and Lambda functions attached to a VPC.
  • NAT bytes processed is a meaningful share of the bill. If the NatGateway-Bytes line is small compared with NatGateway-Hours, endpoints will not change much.
  • A large share of those bytes goes to same-region AWS services. S3, DynamoDB, ECR image pulls, CloudWatch Logs, and similar API traffic are the main candidates.
  • Someone owns the VPC routing and DNS. Endpoints change route tables and name resolution, so the platform or networking team, not individual application teams, should make the change.

The people involved are usually platform or infrastructure engineers who manage VPCs, FinOps or cost owners who track the NAT line items, and security engineers who want to use endpoint policies to restrict data paths.

It is a poor fit if most egress goes to third-party APIs or the internet, if your AWS data lives in other regions, or if each account moves so little traffic to individual services that interface endpoints never pass break-even. Those cases are covered in the sections below.

How does moving AWS traffic to VPC endpoints work?

The idea is to give traffic bound for AWS services a more specific path than the default 0.0.0.0/0 route to the NAT gateway, so the gateway never processes those bytes.

There are two mechanisms:

  1. Gateway endpoints (S3 and DynamoDB only). These add a route to selected route tables. The destination is the service's managed prefix list and the target is the endpoint. VPC routing picks the most specific matching route, so packets to S3 or DynamoDB follow the endpoint route instead of the default route to NAT. Gateway endpoints have no hourly or per-GB charge.
  2. Interface endpoints (most other AWS services). These place an elastic network interface with a private IP in each chosen subnet. With private DNS enabled, the service's standard regional hostname resolves to those private IPs inside the VPC. Traffic then stays on the local VPC route and never reaches NAT. Interface endpoints have an hourly charge per AZ and a per-GB charge lower than NAT's.

In both cases the application code does not change. SDKs and CLIs keep using the same service hostnames. Routing (for gateway endpoints) or DNS (for interface endpoints) moves the traffic. This is also why the DNS and routing pitfalls described later matter: if resolution or routing does not change, the traffic silently stays on NAT.

The rest of the process is measurement. You find which services drive NAT bytes, move the free gateway-endpoint traffic first, add interface endpoints only where volume justifies them, and confirm in Flow Logs and billing that the bytes actually moved.

How do you find which traffic is driving NAT data processing charges?

Start with billing. In the Cost and Usage Report or Cost Explorer, filter on the NAT gateway usage types. These are NatGateway-Hours and NatGateway-Bytes, and each carries a region prefix such as USE1-. Group the results by linked account and by resource ID if your report includes resource IDs. The hourly charge is fixed per gateway. The bytes line is what endpoints can reduce, and its size tells you whether the work is worth doing. If bytes processed is a small part of the bill, stop here.

To see what those bytes are, enable VPC Flow Logs on the NAT gateway's elastic network interface rather than on the whole VPC. This keeps log volume and cost down, and every record you get is traffic the gateway processed. Aggregate bytes by the remote address. For uploads, that is the destination address. For downloads, such as S3 reads, most bytes arrive from the remote side, so group by the source address as well. A common query pattern filters on the NAT interface ID, excludes your VPC CIDR from the remote-address column, sums bytes per address, and sorts descending.

Next, classify the top addresses. Run aws ec2 describe-managed-prefix-lists to find the S3 and DynamoDB lists, named com.amazonaws.<region>.s3 and com.amazonaws.<region>.dynamodb. Then fetch their CIDRs with aws ec2 get-managed-prefix-list-entries. Match other addresses against AWS's published IP ranges file to identify services such as ECR or CloudWatch.

The output is a ranked list of services by bytes, which tells you which endpoint to create first.

#!/usr/bin/env bash
set -euo pipefail

REGION="us-east-1"
LOG_GROUP="/vpc/flowlogs/nat-eni"   # placeholder log group
NAT_ENI="eni-0abc1234def567890"      # NAT gateway's network interface
VPC_CIDR="10.0.0.0/16"               # your VPC range

QUERY="filter interfaceId = '${NAT_ENI}'
| filter not isIpv4InSubnet(srcAddr, '${VPC_CIDR}')
| stats sum(bytes) as totalBytes by srcAddr
| sort totalBytes desc
| limit 25"

QUERY_ID=$(aws logs start-query --region "$REGION" \
  --log-group-name "$LOG_GROUP" \
  --start-time "$(date -d '7 days ago' +%s)" --end-time "$(date +%s)" \
  --query-string "$QUERY" --query queryId --output text)

sleep 15  # Logs Insights queries run asynchronously
aws logs get-query-results --region "$REGION" --query-id "$QUERY_ID" \
  --query 'results[].[?field==`srcAddr`||field==`totalBytes`].value' --output text

for svc in s3 dynamodb; do
  PL_ID=$(aws ec2 describe-managed-prefix-lists --region "$REGION" \
    --filters "Name=prefix-list-name,Values=com.amazonaws.${REGION}.${svc}" \
    --query 'PrefixLists[0].PrefixListId' --output text)
  echo "== ${svc} (${PL_ID})"
  aws ec2 get-managed-prefix-list-entries --region "$REGION" \
    --prefix-list-id "$PL_ID" --query 'Entries[].Cidr' --output text
done

A method sketch that sums NAT gateway Flow Log bytes by remote address in CloudWatch Logs Insights, then retrieves the S3 and DynamoDB managed prefix list CIDRs so the top addresses can be classified by service.

How do VPC gateway endpoints for S3 and DynamoDB work?

A gateway endpoint is not a network interface. Creating one for S3 or DynamoDB adds a route to each route table you select. The destination is the service's AWS-managed prefix list (a pl- ID covering that service's public ranges in the region), and the target is the endpoint. Because a prefix-list route is more specific than 0.0.0.0/0, matching packets bypass the NAT gateway. Gateway endpoints have no hourly charge and no per-GB processing charge. On almost any account, same-region S3 and DynamoDB traffic is the first thing to move: it costs nothing to switch and removes the processing fee for that traffic. Cross-region requests still take the default route.

Container images are the case that surprises people. ECR serves image layers from S3, so a private cluster pulling through NAT pays processing on every layer of every pull. Interface endpoints for ecr.api and ecr.dkr cover authentication and manifests, but they do not cover the layer downloads. Without the S3 gateway endpoint, those bytes still go through NAT.

A private subnet's routing after the change:

Destination Target Traffic
VPC CIDR local ECR API/registry via interface endpoint ENIs (private DNS resolves to them)
S3 prefix list S3 gateway endpoint ECR layers, S3 objects
DynamoDB prefix list DynamoDB gateway endpoint DynamoDB calls
0.0.0.0/0 NAT gateway Everything else

With the AWS CLI, create the S3 gateway endpoint with aws ec2 create-vpc-endpoint --vpc-endpoint-type Gateway --vpc-id <vpc> --service-name com.amazonaws.<region>.s3 --route-table-ids <rtb-a> <rtb-b>, listing every private route table that sends traffic through NAT.

#!/usr/bin/env bash
set -euo pipefail

REGION="us-east-1"
VPC_ID="vpc-0abc1234def567890"

RTBS=$(aws ec2 describe-route-tables \
  --region "$REGION" \
  --filters "Name=vpc-id,Values=$VPC_ID" "Name=route.nat-gateway-id,Values=nat-*" \
  --query 'RouteTables[].RouteTableId' --output text)

echo "Private route tables: $RTBS"

for SVC in s3 dynamodb; do
  aws ec2 create-vpc-endpoint \
    --region "$REGION" \
    --vpc-id "$VPC_ID" \
    --vpc-endpoint-type Gateway \
    --service-name "com.amazonaws.$REGION.$SVC" \
    --route-table-ids $RTBS
done

aws ec2 describe-route-tables \
  --region "$REGION" \
  --route-table-ids $RTBS \
  --query 'RouteTables[].{Table:RouteTableId,Routes:Routes[].[DestinationPrefixListId || DestinationCidrBlock, GatewayId || NatGatewayId]}' \
  --output table

Uses the AWS CLI to find every route table in the VPC that routes through a NAT gateway, attach S3 and DynamoDB gateway endpoints to those tables, and confirm the new prefix-list routes alongside the default NAT route.

When are interface endpoints cheaper than NAT? A break-even calculation

Gateway endpoints only exist for S3 and DynamoDB. Other AWS APIs, such as ECR, CloudWatch Logs, STS, Secrets Manager and SQS, need interface endpoints (PrivateLink). An interface endpoint places an elastic network interface in each subnet you choose. AWS bills it per endpoint, per AZ, per hour, plus a per-GB processing charge that is lower than NAT's. Because of the fixed hourly component, volume determines whether an interface endpoint saves money.

Cost component NAT gateway Gateway endpoint Interface endpoint
Hourly charge Per gateway None Per endpoint, per AZ
Per-GB processing Yes, highest None Yes, lower than NAT
Scales with Gateways × hours + GB Nothing Endpoints × AZs × hours + GB

Break-even (illustrative estimate)

These inputs are assumptions. Check current pricing for your region.

  • NAT processing: $0.045/GB
  • Endpoint hourly rate: $0.01 per AZ
  • Endpoint processing: $0.01/GB
  • AZs: 3
  • Hours per month: 730

The endpoint's fixed cost is 0.01 × 3 × 730 = $21.90/month. Each GB moved off NAT saves 0.045 − 0.01 = $0.035. The break-even volume is 21.90 / 0.035, which is about 626 GB/month for that one service.

A staging account that sends 50 GB/month to Secrets Manager pays about $2.25 through NAT. Behind an endpoint it pays about $22.40. Some services need more than one endpoint, which raises the fixed cost further. ECR, for example, needs both ecr.api and ecr.dkr.

Removing traffic from NAT also leaves its hourly charge in place. You keep paying that charge until no traffic uses the gateway and you delete it. Count only the per-GB savings in the calculation.

When should you avoid or limit VPC endpoints?

Endpoints only remove NAT charges for traffic that actually resolves to and routes through them. Several common setups break that assumption.

Gateway endpoints are route-table entries that point to the S3 or DynamoDB prefix list for the VPC's own region. They do not cover buckets or tables in other regions, so that traffic still goes through NAT. Gateway endpoints are also not transitive. Traffic arriving over VPN, Direct Connect, peering or a transit gateway cannot use them. Interface endpoints fix reachability, but you pay for each one per hour in every AZ, plus a per-GB charge.

Scenario Consequence Recommended alternative
Cross-region S3 or DynamoDB access Bypasses the gateway endpoint and is billed as NAT processing Replicate data into the consuming region, or accept the NAT cost
On-premises or peered-VPC clients Cannot reach the gateway endpoint S3 interface endpoint, sized against measured volume
Many services × many AZs Hourly charges grow with every endpoint and every AZ Deploy only for services above break-even. Use fewer AZs for low-volume services
Custom DNS resolvers, split-horizon zones, pinned endpoint URLs or IPs Names keep resolving to public IPs, so traffic stays on NAT without any error Forward AWS service zones to the VPC resolver, then verify resolution from inside the workload
Centralized endpoints in a shared-services VPC Adds transit gateway processing, cross-AZ transfer and shared private hosted zones Centralize only low-volume services. Keep high-volume endpoints local

The DNS case is the most dangerous because nothing fails. Clients keep working while the NAT bill stays the same, so check resolved addresses as well as connectivity.

How do cross-AZ transfer and endpoint policies affect cost and security?

A private subnet whose route table points at a NAT gateway in another Availability Zone pays twice. You pay the NAT data processing charge, and you also pay inter-AZ data transfer for every byte that crosses the zone boundary. Interface endpoints behave the same way when a client resolves to an endpoint network interface in a different AZ. Gateway endpoints for S3 and DynamoDB avoid this because they work through route tables and have no zonal interface.

The usual fix is one NAT gateway per AZ, with each private subnet's route table pointing at the NAT in its own zone, and interface endpoints deployed in every AZ that calls them. This adds hourly charges, but it also stops one zone's failure from cutting off egress for the others. Consolidating to a single NAT gateway to save on hourly fees often backfires: once the other zones' traffic starts paying cross-AZ transfer, the saving can disappear. Check your per-AZ byte counts before you consolidate.

Endpoints also give you a security control. An endpoint policy can limit which buckets, tables, or actions are reachable through the endpoint. On the bucket side, a policy can deny any request whose aws:SourceVpce value does not match your endpoint ID. For example, a single Deny statement on s3:* for the bucket and its objects, conditioned on StringNotEquals against your endpoint ID, makes the data reachable only through that path. The cost change then doubles as an exfiltration control.

Be careful with restrictive endpoint policies. AWS-owned buckets back operating system package repositories and ECR image layers, so an allow-list that omits them breaks yum/dnf installs and container pulls. These failures show up as timeouts or access-denied errors in build jobs or node bootstrap logs, often days after the policy change and in a different team's system. That distance makes the cause hard to trace back.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DenyAccessOutsideVpcEndpoint",
      "Effect": "Deny",
      "Principal": "*",
      "Action": "s3:*",
      "Resource": [
        "arn:aws:s3:::example-app-data",
        "arn:aws:s3:::example-app-data/*"
      ],
      "Condition": {
        "StringNotEquals": {
          "aws:SourceVpce": "vpce-0a1b2c3d4e5f67890"
        }
      }
    }
  ]
}

A bucket policy that denies all S3 actions on the bucket and its objects unless the request arrives through the named VPC endpoint. Test it before applying, because it also blocks console and admin access from outside that endpoint.

How do you roll out VPC endpoints safely, and what is NAT still needed for?

A safe rollout depends on proving that each step moved the traffic you expected. Follow this sequence:

  1. Measure the baseline. Record a week or more of bytes processed per NAT gateway, along with the Flow Log share going to S3 and DynamoDB prefixes. Without a baseline, you cannot tell a real reduction from a quiet week.
  2. Add gateway endpoint routes in a low-traffic window. Associating an endpoint with a route table adds a more specific prefix-list route. Existing connections to those destinations can reset when their path changes. Long-running uploads, streaming reads, and connection pools hit this first, so schedule the change and roll it out one route table at a time.
  3. Confirm in Flow Logs. Filter on the NAT gateway's network interface and check that flows to S3 and DynamoDB addresses stop appearing there. Any remaining flows usually come from a subnet whose route table you missed, or from traffic to a bucket in another Region, which a gateway endpoint does not cover.
  4. Watch NAT bytes processed fall. Billing data lags, so judge the result over several days rather than hours.

Then update your dashboards and chargeback models. Traffic that used to show up as NAT data processing either moves to interface endpoint line items or disappears because gateway endpoints are free. Teams billed on NAT usage will see their costs shift, and someone should explain that change before they ask about it.

NAT is still required for anything outside AWS's endpoint coverage: third-party APIs, external package registries, and SaaS endpoints. For workloads that can use IPv6, an egress-only internet gateway handles outbound traffic without NAT processing charges. Standard data transfer out to the internet still applies.

How can moving traffic to VPC endpoints save engineering time?

The main benefit is lower cost, but the change also removes recurring work.

  • Fewer NAT bill investigations. When S3, DynamoDB, and ECR layer traffic go through NAT, every spike in data pulls, log volume, or image pulls shows up as an unexplained jump in NatGateway-Bytes. Someone then has to go through Flow Logs to find the cause. Once that traffic moves to endpoints, the NAT line mostly reflects real external egress, so changes in it are easier to explain and happen less often.
  • Clearer cost attribution. Interface endpoint charges are tied to a specific service, and gateway endpoint traffic stops appearing as a cost at all. Chargeback discussions get simpler when "NAT" no longer combines S3 reads, log shipping, and third-party API calls into one number.
  • Less pressure on NAT connection limits. A NAT gateway has a limit on simultaneous connections to each unique destination, and it reports port allocation failures through the ErrorPortAllocation CloudWatch metric. Busy clusters that make many parallel connections to S3 or other AWS APIs can hit this limit, and the result is intermittent connection errors that are slow to debug. Moving that traffic to endpoints takes it out of the NAT connection table completely.
  • Configure once and reuse. Endpoints are defined once per VPC, preferably in the same infrastructure-as-code module that creates the VPC. New services and clusters in that VPC get the private paths automatically, and application teams do not change any code, because SDKs keep using the standard service hostnames.
  • Security controls come with the change. Endpoint and bucket policies that use aws:SourceVpce give you an enforceable data-path restriction. In some setups, that replaces separately maintained egress allow-lists for AWS services.

The work is not free. Expect upfront effort to measure traffic, test DNS resolution, review endpoint policies, and roll out route changes carefully, as described above. Interface endpoints also add resources that need to be maintained in every AZ and account. The time savings come after that first effort, mostly from fewer cost surprises and fewer NAT-related connection problems.

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.