Sub topic 5
Why NAT gateways inflate the bill
This chapter assumes you know VPCs, public and private subnets, route tables, and how to read a bill by usage type. It explains why a NAT gateway often becomes one of the largest line items in an AWS account, and how to confirm that before you change anything.
What a NAT gateway charges for
A NAT gateway lets instances in a private subnet reach the internet without being reachable from it. AWS bills it in two parts:
- An hourly charge for each gateway, whether or not traffic flows.
- A data processing charge for every gigabyte that passes through it, in either direction.
The second charge is the one that grows. In us-east-1 it is about $0.045 per GB. Check the current price for your Region on the NAT Gateway pricing page, because rates vary.
The processing charge is separate from normal data transfer. Traffic leaving to the internet through a NAT gateway pays the NAT processing fee and also the standard internet egress fee. The same gigabyte can be billed twice.
Where the extra cost comes from
The processing fee applies to all bytes, so it hits traffic you might not expect to be expensive.
- Traffic to AWS services. An instance in a private subnet that reads from S3 or DynamoDB sends that traffic through the NAT gateway by default. The destination is an AWS service in the same Region, so there is no internet egress fee. You still pay the processing fee on every byte.
- Inbound downloads. Pulling container images, OS packages, or large datasets from the internet is billed on the way in. Ingress to AWS is free, but the NAT gateway still processes it.
- Cross-AZ hops. If an instance in one AZ uses a NAT gateway in another AZ, you also pay inter-AZ transfer on top of processing.
Confirm it in Cost Explorer
Look at usage types, not service totals. NAT gateway costs appear under Amazon VPC in the following usage types, each prefixed by a Region code:
| Usage type contains | Meaning |
|---|---|
| `NatGateway-Hours` | Fixed hourly charge |
| `NatGateway-Bytes` | Data processing charge |
| `DataTransfer-Regional-Bytes` | Inter-AZ transfer, which may include cross-AZ NAT use |
If NatGateway-Bytes is much larger than NatGateway-Hours, traffic volume is the problem, not the number of gateways. The aws ce get-cost-and-usage command from the earlier Cost Explorer chapter, filtered on NatGateway-Bytes, shows this directly.
Find who is sending the bytes
Cost Explorer tells you the gateway is expensive, not which instance or destination is responsible. Enable VPC Flow Logs on the NAT gateway's network interface and group by source. The Flow Logs chapter shows the query. If most bytes go to addresses in the S3 or DynamoDB prefix ranges, a gateway endpoint will remove them. If they go to a package mirror or a SaaS API, you need another approach, such as caching or an interface endpoint.
Common errors
- Assuming S3 traffic from a private subnet is free because it stays in AWS. It is free of egress fees, not of NAT processing fees.
- Putting one NAT gateway in a single AZ and routing all subnets to it. This adds inter-AZ charges. Cheaper is not always one gateway, so weigh the hourly fee against the transfer fee.
- Deleting a NAT gateway to save money without checking for workloads that depend on it for updates or API calls.
Exercise
A private-subnet instance copies 2 TB a month from S3 in the same Region through a NAT gateway priced at $0.045 per GB. What does NAT data processing add, and what removes it?
Show answer
2 TB is about 2,000 GB, so processing adds roughly $90 a month (2,000 × $0.045). There is no internet egress fee for same-Region S3 traffic. An S3 gateway endpoint added to the subnet's route table sends that traffic around the NAT gateway and removes the processing charge.