How is NAT Gateway pricing structured, and why do data processing fees dominate?
A NAT Gateway bill has two native components, and a third that shows up on other line items.
- Hourly charge. Each NAT Gateway is billed for every hour it exists, whether it carries traffic or not. The recommended highly available pattern is one gateway per Availability Zone, so a three-AZ VPC pays this charge three times.
- Data processing charge. Every gigabyte that passes through the gateway is billed, in either direction. It does not matter whether the destination is the public internet or an AWS service in the same region, such as S3, ECR, or DynamoDB.
- Data transfer. Normal data transfer charges apply on top of processing. These include internet egress and cross-AZ traffic when a subnet routes to a gateway in a different AZ.
The hourly charge is a fixed floor. The processing charge scales with traffic, so it usually dominates in busy private subnets.
Illustrative estimate. Assume $0.045 per gateway-hour, $0.045 per GB processed, three gateways, and 50 TB per month through NAT.
- Hourly: 3 × 730 hours × $0.045 ≈ $99
- Processing: 51,200 GB × $0.045 ≈ $2,304
Processing is more than 95% of the NAT line in this example. These rates are assumptions for the calculation. Check current rates for your region on the AWS pricing page before modelling your own bill.
This matters most to backend and platform teams whose private-subnet workloads talk heavily to AWS services. Common examples are container image pulls, log and metric shipping, S3-backed data pipelines, and backups. For these teams, much of the processed traffic never needed to leave AWS's network, which makes it the easiest part of the bill to cut.
Who should use VPC endpoints to reduce NAT Gateway cost?
This approach is aimed at engineers who own VPC design and the AWS bill for it:
- Platform and infrastructure teams that run workloads in private subnets with a NAT Gateway as the default route. This includes EC2 fleets, ECS and EKS clusters, and Lambda functions attached to a VPC.
- Teams running container platforms that pull images from ECR frequently. Autoscaling, frequent deployments and short-lived tasks all repeat image pulls, and the layer bytes come from S3.
- Data engineering teams whose pipelines read and write large volumes to S3 or DynamoDB in the same region from private compute.
- Engineers responsible for cloud cost, who need to explain a NAT line item and decide which changes are worth making.
- Security-focused teams that want AWS service traffic to stay on private routes and want a place to enforce endpoint and bucket policies.
If your workloads run in public subnets with public IPs, or your VPCs carry little traffic to AWS services, the cost argument is weak. The security controls in the policy section may still be relevant.
When should you use VPC endpoints instead of the NAT path?
Use them when the measurements from the next section point to them:
- NAT bytes dominate the NAT bill. If the
NatGateway-Bytesusage type is much larger thanNatGateway-Hours, traffic is the cost driver and endpoints can remove part of it. - Same-region S3 or DynamoDB traffic crosses NAT. Gateway endpoints for these services have no hourly or per-GB charge, so for private subnets that reach S3 or DynamoDB in the same region there is rarely a cost reason not to add them.
- ECR image pulls are a large share of traffic. The combination of the S3 gateway endpoint plus the
ecr.apiandecr.dkrinterface endpoints moves the whole pull off NAT. - An interface-endpoint service is above break-even. Use the formula in the break-even section with your region's rates. Services such as CloudWatch Logs can carry enough volume to justify an endpoint, while others only make occasional calls.
- Subnets should have no internet route at all. Endpoints let isolated subnets reach the AWS services they need without a NAT Gateway, which also removes that gateway's hourly charge.
When should you avoid VPC endpoints or hold off on them?
Endpoints are not the right fix in several situations:
- The NAT hourly charge dominates. If traffic is light and the bill is mostly gateway-hours, consolidating or removing NAT Gateways matters more than endpoints. Interface endpoints would add their own hourly charges.
- Interface endpoint traffic is below break-even. A service that sends a few GB a month costs less over NAT than through an endpoint billed hourly in every AZ.
- The traffic goes to another region or the internet. Gateway endpoints only cover same-region S3 and DynamoDB. Cross-region buckets, public package registries and third-party APIs need the alternatives listed later in this article.
- The fixed cost multiplies across many VPCs and AZs. Deploying every interface endpoint into every VPC can cost more than the NAT processing it removes. Either deploy selectively or evaluate a centralized design, accepting its transfer and DNS costs.
- DNS is not under your control. If workloads use custom resolvers that don't forward to the VPC resolver, private DNS for interface endpoints has no effect until resolution is fixed.
- Some workloads depend on the public endpoint. Private DNS overrides the public hostname for the whole VPC. Check for workloads that rely on that behaviour before enabling it.
- You haven't audited S3 access yet. Hold off on restrictive endpoint policies until CloudTrail data events show which buckets, including AWS-owned and third-party ones, each VPC uses.
How do you find out what traffic is flowing through your NAT Gateway?
Start with billing data, because it tells you whether the problem is worth solving. In Cost Explorer, group by usage type and filter for entries containing NatGateway-Bytes, which carry a region prefix. Compare them with NatGateway-Hours. If bytes dominate, endpoints are likely to help. If hours dominate, consolidating NAT Gateways matters more.
Cost Explorer shows how much you pay but not where the traffic goes. CloudWatch narrows it down per gateway. In the AWS/NATGateway namespace, BytesOutToDestination measures traffic leaving toward the internet or AWS public endpoints, and BytesInFromDestination measures what comes back. A gateway with large inbound volume usually points to downloads such as image pulls or S3 reads. Large outbound volume suggests log shipping or uploads.
To find out which destinations account for the bytes, enable VPC Flow Logs on the NAT Gateway's network interface. Then run an aggregation in CloudWatch Logs Insights or Athena that groups records by destination address, sums the bytes field, sorts descending and keeps the top results. A small number of addresses typically accounts for most of the volume.
Map those addresses to services using AWS's published IP ranges file, which tags prefixes by service and region. Two caveats apply:
- Many prefixes appear only under the generic
AMAZONentry, so some addresses won't resolve to a specific service. - The ranges change over time, so match against a current copy of the file.
Flow logs have their own ingestion and storage costs. A capture limited to a few representative days, or filtered to the NAT interface only, is usually enough. It shows which flows are worth an endpoint, so you don't build endpoints for traffic that barely registers.
fields srcAddr, dstAddr, bytes
| filter srcAddr = "10.0.1.25" and not isIpv4InSubnet(dstAddr, "10.0.0.0/16")
| stats sum(bytes) as totalBytes, count(*) as records by dstAddr
| sort totalBytes desc
| limit 20
fields srcAddr, dstAddr, bytes
| filter dstAddr = "10.0.1.25" and not isIpv4InSubnet(srcAddr, "10.0.0.0/16")
| stats sum(bytes) as totalBytes by srcAddr
| sort totalBytes desc
| limit 20
Two CloudWatch Logs Insights queries that rank external addresses by bytes sent through and received by the NAT Gateway, so you can map the top entries to AWS services with the published IP ranges file.
How do VPC endpoints keep AWS service traffic off the NAT Gateway?
Each endpoint type changes routing in a different way. That difference decides what you pay and which clients can use it.
Default path:
private subnet --> route 0.0.0.0/0 --> NAT Gateway --> IGW --> S3 / STS / SQS
(per-GB processing)
Gateway endpoint (S3, DynamoDB):
private subnet --> route <service prefix list> --> vpce (gateway) --> S3
(longest-prefix match wins over 0.0.0.0/0)
Interface endpoint (PrivateLink):
private subnet --> DNS resolves sqs.<region>... to private IP
--> ENI in your subnet --> SQS
A gateway endpoint adds a route table entry whose destination is the AWS-managed prefix list for S3 or DynamoDB in that region. The prefix list is more specific than the default route, so matching packets bypass the NAT Gateway without any change to DNS or application code. Gateway endpoints have no hourly or per-GB charge. They only work for same-region buckets and tables, and only for traffic that starts inside the VPC.
An interface endpoint places an ENI in each subnet you select. Private DNS makes the service's public hostname resolve to those ENI addresses. You pay an hourly charge per AZ plus a per-GB processing fee of its own, so interface endpoints for ECR API, STS, CloudWatch Logs, SQS, Secrets Manager or KMS reduce cost only when the traffic volume justifies them.
| Gateway endpoint | Interface endpoint | NAT path | |
|---|---|---|---|
| Cost model | Free | Hourly per AZ + per-GB | Hourly + per-GB |
| Services | S3, DynamoDB | Most AWS services | Any internet destination |
| Reachability | In-VPC only, same region | Also peered VPCs, VPN, Direct Connect | Outbound from VPC |
| DNS | Public names unchanged | Private DNS overrides public name | Public resolution |
+------------------------ VPC (single region) -------------------------+
| +----------------------- private subnet -----------------------+ |
| | workload (EC2 instance / ECS task) | |
| | | | |
| | +-- next hop chosen by route table and DNS | |
| | +-+-------------+------------------------+ | |
| | | | | | |
| | | S3/DDB prefix | sqs.<region> resolves | 0.0.0.0/0 | |
| | | list route | to ENI private IP | default route | |
| | | v | | |
| | | +-----------+ | | |
| | | | interface | | | |
| | | | endpoint | | | |
| | | | ENI / AZ | | | |
| | | +-----+-----+ | | |
| +--|---------------|------------------------|------------------+ |
| v | v |
| +---+-----+ | +-------+--------+ |
| | vpce gw | | | NAT Gateway | |
| | (free) | | | hourly + $/GB | |
| +---+-----+ | +-------+--------+ |
| | | v |
| | | +-------+--------+ |
| | | |Internet Gateway| |
| | | +-------+--------+ |
+-----|---------------|------------------------|-----------------------+
v v v
S3 / DynamoDB SQS, STS, KMS, ... public AWS endpoints
Three paths out of a private subnet: the S3/DynamoDB prefix-list route sends traffic to a free gateway endpoint, private DNS sends service hostnames to a billed interface endpoint ENI, and everything else follows 0.0.0.0/0 through the NAT Gateway, which charges per GB processed.
When does an interface endpoint cost less than NAT? A break-even calculation
Interface endpoints are not free. Each one bills an hourly charge in every AZ where it has a network interface, plus a per-GB processing fee. Removing traffic from NAT only pays off once the per-GB savings cover that fixed cost.
The break-even formula, where F is the fixed monthly endpoint cost, n is the NAT per-GB rate, and e is the endpoint per-GB rate:
Break-even GB/month = F ÷ (n − e), where F = AZs × hourly rate × hours per month
Illustrative estimate (assumed numbers, not a benchmark). Check current pricing for your region before using these rates.
| Input / result | Assumed value |
|---|---|
| AZs with endpoint ENIs | 3 |
| Endpoint hourly rate per AZ | $0.01 |
| Hours per month | 730 |
| NAT processing (n) | $0.045/GB |
| Endpoint processing (e) | $0.01/GB |
| Fixed cost F | $21.90/month |
| Break-even volume | ≈ 626 GB/month |
| At 2,000 GB: NAT cost | $90.00 |
| At 2,000 GB: endpoint cost | $41.90 |
This calculation counts only NAT processing fees. The NAT Gateway's own hourly charge stays the same unless you remove the gateway entirely.
When to skip interface endpoints:
- Low-volume services. A service sending a few GB a month, such as an occasional secrets lookup, costs less on NAT than the endpoint's fixed fee.
- Many VPCs and AZs. Multiply F by every service, VPC, and AZ before deploying endpoints everywhere.
Centralizing endpoints in a shared VPC cuts the hourly cost but adds two problems:
- Transit Gateway or peering charges. Any per-GB transfer charge adds to e. If e moves close to n, the savings disappear.
- DNS complexity. You must share private hosted zones with each spoke VPC. That setup is extra operational work, and misconfigured resolution can silently send traffic back through NAT.
How do you implement S3 gateway endpoints and ECR endpoints correctly?
Start with the S3 gateway endpoint, because it carries the most bytes and costs nothing. A gateway endpoint works by adding a route to each associated route table. The destination is the regional S3 prefix list and the target is the endpoint. Associate it with every route table used by private subnets. Each subnet that is missed keeps sending S3 traffic through NAT. Nothing fails, so the gap stays invisible until the bill arrives.
ECR image pulls show why one endpoint is rarely enough. A pull involves three separate traffic paths:
ecr.apihandles authentication and registry API calls.ecr.dkrserves the Docker registry protocol, including manifests.- S3 serves the image layers, which are almost all of the bytes.
If you create only the two ECR interface endpoints, the large layer downloads still go through NAT. If you create only the S3 endpoint, the API calls still need NAT, so subnets without a NAT route fail to pull. You need all three endpoints.
For each interface endpoint:
- Place it in the private subnets, with one per Availability Zone you use.
- Enable private DNS. The VPC must have DNS support and DNS hostnames turned on.
- Attach a security group that allows inbound TCP 443 from the workload subnet CIDRs.
Know the trade-offs before you enable this:
- Private DNS affects the whole VPC. It overrides the public service hostname for every workload in the VPC, including workloads that deliberately used the public endpoint.
- Custom DNS can bypass it. Resolvers that don't forward to the VPC resolver never see the private records, so their clients keep using NAT.
- Gateway endpoints don't route transitively. On-premises networks and peered VPCs can't reach them through transit routing. Those clients need an S3 interface endpoint instead, which has hourly and per-GB charges.
#!/usr/bin/env bash
set -euo pipefail
REGION=us-east-1
VPC_ID=vpc-0abc1234def567890
PRIVATE_RTS="rtb-0aaa1111 rtb-0bbb2222 rtb-0ccc3333"
PRIVATE_SUBNETS="subnet-0aaa1111 subnet-0bbb2222 subnet-0ccc3333"
WORKLOAD_CIDRS="10.0.0.0/19 10.0.32.0/19 10.0.64.0/19"
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_RTS
aws ec2 modify-vpc-attribute --vpc-id "$VPC_ID" --enable-dns-support '{"Value":true}'
aws ec2 modify-vpc-attribute --vpc-id "$VPC_ID" --enable-dns-hostnames '{"Value":true}'
SG_ID=$(aws ec2 create-security-group --region "$REGION" --vpc-id "$VPC_ID" \
--group-name vpce-https --description "HTTPS to interface endpoints" \
--query GroupId --output text)
for cidr in $WORKLOAD_CIDRS; do
aws ec2 authorize-security-group-ingress --region "$REGION" --group-id "$SG_ID" \
--protocol tcp --port 443 --cidr "$cidr"
done
for svc in ecr.api ecr.dkr; do
aws ec2 create-vpc-endpoint --region "$REGION" --vpc-id "$VPC_ID" \
--vpc-endpoint-type Interface --service-name "com.amazonaws.$REGION.$svc" \
--subnet-ids $PRIVATE_SUBNETS --security-group-ids "$SG_ID" \
--private-dns-enabled
done
AWS CLI script that creates the S3 gateway endpoint on all private route tables, then the ecr.api and ecr.dkr interface endpoints with private DNS and an HTTPS-only security group, so every part of an ECR image pull bypasses NAT.
How can endpoint policies and bucket policies restrict access without breaking workloads?
An endpoint is also a control point. Every request that crosses it is evaluated against the endpoint policy, which can only narrow what IAM already allows; it never grants anything. The default policy allows everything. Replacing it with one that allows s3:GetObject, s3:PutObject and s3:ListBucket only on your organization's buckets (for example, conditioned on aws:ResourceOrgID) stops a compromised workload from copying data to an attacker-controlled bucket through the same route.
The bucket side works in the other direction. A bucket policy statement that denies access when aws:SourceVpce does not equal your endpoint ID means the data can only be read from inside that VPC. Exempt a break-glass administrative role from the deny. Otherwise you also block console access, CI pipelines and other accounts that legitimately reach the bucket over a different path.
The risk is in buckets you don't own. ECR stores image layers in an AWS-managed S3 bucket. OS package repositories and some vendor agents also download from S3. An org-scoped endpoint policy blocks all of these. The failure shows up as a generic AccessDenied or a stalled docker pull, so it's easy to blame IAM instead.
Roll out restrictive policies gradually:
- Keep the default policy.
- Enable S3 data events in CloudTrail and record which buckets each VPC actually touches.
- Write explicit allow statements for the AWS-owned and third-party buckets on that list.
- Tighten the policy in one non-production VPC first.
Keep the previous policy versioned so you can revert in a single change.
VPCE=vpce-0a1b2c3d4e5f67890
aws ec2 describe-vpc-endpoints --vpc-endpoint-ids "$VPCE" \
--query 'VpcEndpoints[0].PolicyDocument' --output text > endpoint-policy.previous.json
cat > endpoint-policy.json <<'EOF'
{"Version": "2012-10-17", "Statement": [
{"Sid": "OrgBucketsOnly", "Effect": "Allow", "Principal": "*",
"Action": ["s3:GetObject", "s3:PutObject", "s3:ListBucket"], "Resource": "*",
"Condition": {"StringEquals": {"aws:ResourceOrgID": "o-exampleorgid"}}},
{"Sid": "EcrImageLayers", "Effect": "Allow", "Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::prod-us-east-1-starport-layer-bucket/*"}
]}
EOF
aws ec2 modify-vpc-endpoint --vpc-endpoint-id "$VPCE" --policy-document file://endpoint-policy.json
cat > bucket-policy.json <<'EOF'
{"Version": "2012-10-17", "Statement": [
{"Sid": "DenyOutsideVpce", "Effect": "Deny", "Principal": "*", "Action": "s3:*",
"Resource": ["arn:aws:s3:::example-prod-data", "arn:aws:s3:::example-prod-data/*"],
"Condition": {
"StringNotEquals": {"aws:SourceVpce": "vpce-0a1b2c3d4e5f67890"},
"ArnNotEquals": {"aws:PrincipalArn": "arn:aws:iam::111122223333:role/BreakGlassAdmin"}}}
]}
EOF
aws s3api put-bucket-policy --bucket example-prod-data --policy file://bucket-policy.json
Backs up the existing endpoint policy, then applies an org-scoped S3 endpoint policy with an explicit allow for the ECR layer bucket, and a bucket policy that denies access from outside the endpoint except for a break-glass role.
What NAT costs do VPC endpoints not fix, and what are the alternatives?
Endpoints only help with traffic that is destined for supported AWS services in the same region. Three cost drivers remain after you deploy them.
Cross-AZ routing to NAT. If a private subnet in one AZ routes to a NAT Gateway in another AZ, you pay cross-AZ data transfer on top of the NAT data processing fee. Teams often create this setup on purpose to save the hourly charge for one NAT per AZ. The saving is partly cancelled by transfer charges that grow with traffic. It also adds a failure mode: if the AZ hosting the NAT goes down, every AZ that routes through it loses egress.
Cross-region S3. A gateway endpoint only covers buckets in the VPC's own region. Requests to a bucket in another region still go through NAT and also incur inter-region transfer. The durable fix is to move the data closer to the workloads, either by replicating the bucket or by running those workloads in the bucket's region.
Internet egress. Package registries, container images on public registries, and third-party APIs have no endpoint. A caching proxy or registry mirror cuts repeated downloads, but you then run, patch and scale that component yourself.
| Cost driver | Mitigation | Trade-off |
|---|---|---|
| Cross-AZ path to NAT | One NAT per AZ with AZ-local route tables | Higher hourly cost |
| Cross-region S3 | Replicate the data or co-locate the compute | Replication storage and transfer cost |
| Package registries | Caching proxy or mirror | Operational ownership and staleness |
| External APIs | Batch requests and compress payloads | Changes to application code |
How do you verify that VPC endpoints actually reduced NAT Gateway cost?
Pull the NAT Gateway's CloudWatch metrics for equal windows before and after the change. Use the same weekdays and a full billing cycle if possible, because batch jobs and month-end reports distort short samples. Data processing is billed on bytes the gateway processes in both directions, so sum BytesOutToDestination and BytesInFromDestination per gateway. For example: aws cloudwatch get-metric-statistics --namespace AWS/NATGateway --metric-name BytesInFromDestination --dimensions Name=NatGatewayId,Value=<nat-id> --statistics Sum --period 86400 --start-time <start> --end-time <end>. Then check the result against the NAT Gateway bytes usage type in your billing data. The metric tells you whether traffic moved off the gateway. The bill tells you whether you actually pay less.
Next, check the flow logs for the NAT Gateway's ENI. After the S3 gateway endpoint is in place, the NAT ENI should no longer show destination addresses from the S3 prefix list. Gateway endpoints have no ENI, so S3 traffic now appears only on the instance's ENI, routed through the endpoint.
If S3 or ECR traffic still crosses the NAT, look for these common causes:
- Hard-coded endpoint URLs. An application may name a specific Region or a global hostname that does not match the endpoint's service name.
- Host-level proxy settings. Variables like
HTTPS_PROXYwithout a matchingNO_PROXYentry send traffic to a proxy that egresses through the NAT. - SDKs targeting a different Region. Requests to a bucket in another Region cannot use a same-Region gateway endpoint.
Treat each endpoint as a measure, change, verify cycle. Start with the largest traffic source, deploy one endpoint, and confirm the bytes dropped before moving on. This keeps engineering time focused on changes that pay off. It also exposes interface endpoints that carry no traffic and only add hourly charges, so you can remove them.
How can this approach save engineering time?
Most of the saving comes from the order of work and from changes that need no application involvement:
- Gateway endpoints need no code changes. The S3 and DynamoDB gateway endpoints work through route tables. Applications keep the same hostnames and SDK configuration, so there is no coordination with application teams, no redeploys and no new client settings to test.
- Measuring first avoids wasted work. The billing check tells you whether bytes or hours drive the cost before anyone builds anything. The flow log query ranks destinations, so effort goes to the few addresses that carry most of the volume instead of creating endpoints for every service.
- The break-even formula replaces debate with arithmetic. With your region's rates and the measured volume, deciding whether an interface endpoint is worth it is a short calculation rather than a design discussion for each service.
- The setup is repeatable. The CLI steps above, or the same resources in your infrastructure-as-code tool, can become one reusable module per VPC. New VPCs get the same endpoints, security group and DNS settings without rework.
- Fewer egress dependencies for image pulls. With the S3,
ecr.apiandecr.dkrendpoints in place, ECR pulls no longer depend on the NAT path. That removes one category of failure to investigate when a NAT Gateway or its route has a problem, and it lets isolated subnets pull images without extra networking work. - Known failure modes shorten debugging. The usual causes of traffic that still crosses NAT, such as missed route tables, custom resolvers, proxy variables, hard-coded endpoints and cross-region requests, form a checklist. Working through it is faster than starting from raw packet data.
- Staged policy rollout avoids outages. Auditing bucket access with CloudTrail before tightening endpoint policies, and keeping the previous policy for a one-step revert, prevents the
AccessDeniedand stalled-pull incidents that would otherwise consume on-call time.
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.