Sub topic 3
Finding transfer costs in Cost Explorer
This chapter assumes you can run the AWS CLI, know what a Region and an Availability Zone (AZ) are, and can read a billing report. By the end you will know how to turn a vague "data transfer is expensive" into a ranked list of usage types.
Why usage types matter
Data transfer rarely appears as one line item. Cost Explorer groups it under services such as EC2, S3, or CloudFront, and the dollars are spread over many transfer paths. The dimension that separates those paths is usage type. Each usage type names a billed quantity, for example USE1-DataTransfer-Out-Bytes or USE1-NatGateway-Bytes. The prefix is a Region code (USE1 is us-east-1). Usage types in Regions other than us-east-1 get their own prefix.
These patterns cover most transfer spend:
| Usage type pattern | What it usually means |
|---|---|
| `DataTransfer-Out-Bytes` | Traffic from AWS to the internet |
| `DataTransfer-Regional-Bytes` | Traffic between AZs in the same Region |
| `USE1-USW2-AWS-Out-Bytes` | Traffic from one Region to another (source and destination codes appear in the name) |
| `NatGateway-Bytes` | Data processed by a NAT gateway |
| `NatGateway-Hours` | The hourly charge for the gateway, which is not a transfer charge |
Reading the console
- Open Cost Explorer and choose a monthly or daily view for the last one to three months.
- Set Group by to Usage type.
- Filter Service to the services you suspect, or leave it open for the whole account.
- Sort by cost and look at the top entries. Ignore compute and storage usage types.
Then change Group by to Linked account or a cost allocation tag, and filter to one usage type. This tells you who owns the spend.
Doing it from the CLI
The same query works in a script, which helps when you want to run it every month.
aws ce get-cost-and-usage \
--time-period Start=2026-10-01,End=2026-11-01 \
--granularity MONTHLY \
--metrics UnblendedCost \
--group-by Type=DIMENSION,Key=USAGE_TYPE \
--query "ResultsByTime[].Groups[?contains(Keys[0], 'DataTransfer') || contains(Keys[0], 'NatGateway-Bytes')].[Keys[0], Metrics.UnblendedCost.Amount]" \
--output textThe End date is exclusive, so End=2026-11-01 covers all of October. The --query filter runs on your machine after the data returns. It keeps names containing DataTransfer or NatGateway-Bytes and prints the usage type and its cost.
Common errors
- Missing inter-Region charges. Names like
USE1-USW2-AWS-Out-Bytesdo not containDataTransfer, so the CLI filter above skips them. Add acontains(Keys[0], 'AWS-Out-Bytes')clause if you replicate between Regions. - Blaming the wrong service. Inter-AZ traffic is billed under EC2 even when a database or load balancer causes it. Group by usage type first, not by service.
- Reading the NAT gateway as one number.
NatGateway-Hoursis fixed per gateway. OnlyNatGateway-Bytesgrows with traffic. - Comparing partial months. The current month is incomplete. Compare full months, or use daily granularity.
- Surprise API costs. Each Cost Explorer API request costs $0.01, so avoid calling it in a tight loop.
Cost Explorer tells you how much each path costs, not which resources generate the traffic. The next chapter uses VPC Flow Logs to find those resources.
Exercise
Last month's report shows high USE1-DataTransfer-Regional-Bytes cost and low DataTransfer-Out-Bytes cost. Which traffic path is the likely cause, and why can't you tell which service is responsible by grouping by service alone?
Show answer
The regional usage type means traffic between AZs in us-east-1, so inter-AZ traffic is the likely cause. Cost Explorer bills it under EC2 regardless of which application produces it, so grouping by service hides the real source. You need to group by usage type, then by account or tag, and then use VPC Flow Logs to find the resources.