Sub topic 3
Finding transfer costs in Cost Explorer
This chapter assumes you know what regions, Availability Zones (AZs), VPCs, and subnets are. It also assumes you can run AWS CLI commands and read basic JSON or text output. You do not need to know how data transfer is priced in detail. The earlier chapters covered the categories, and this one shows you where each category appears on your bill.
Why start with Cost Explorer
You can't reduce a cost you can't see. Data transfer charges are scattered across services. An EC2 instance sending data to the internet, a NAT gateway processing bytes, and an S3 replication rule all bill under different line items. Cost Explorer is the AWS billing tool that lets you slice your spend by service, region, account, tag, and usage type. For transfer costs, usage type is the most useful slice.
The goal of this chapter is to answer one question: which transfer category costs the most in this account? Once you know that, you can pick the right fix from the later chapters.
The service view is not enough
The first instinct is to group by service. That view often misleads for transfer costs, for two reasons.
- Many transfer charges are billed under the service that generates the traffic. Internet egress from an EC2 instance appears under Amazon EC2, even though the cause is an application.
- Some of the biggest line items sit under the service "EC2-Other". This bucket contains NAT gateway charges, inter-AZ transfer, and EBS charges together. It tells you nothing about which of them is growing.
So treat the service view as a starting point only. If "EC2-Other" is large, filter to that service and regroup by usage type.
Reading usage types
A usage type is a string that names exactly what was metered. The format varies by service, but transfer usage types follow recognizable patterns. The prefix often shows the region, using a short code such as USE1 for us-east-1 or EUW1 for eu-west-1. The rest describes the traffic.
| Usage type pattern | What it measures |
|---|---|
| `DataTransfer-Out-Bytes` | Data leaving AWS to the internet from a region |
| `DataTransfer-Regional-Bytes` | Data moving between AZs in the same region |
| `<region>-<region>-AWS-Out-Bytes` | Data sent from one region to another |
| `NatGateway-Bytes` | Bytes processed by a NAT gateway |
| `NatGateway-Hours` | Hourly charge for each NAT gateway |
| `CloudFront-Out-Bytes` (varies by edge region) | Data served from CloudFront edge locations |
Two details trip people up.
First, DataTransfer-Regional-Bytes is billed on both sides of an inter-AZ transfer. The sender pays for outbound bytes and the receiver pays for inbound bytes, so the line often looks double what you expect. Check the per-gigabyte rate in the current pricing page before you estimate savings.
Second, NatGateway-Bytes and NatGateway-Hours are different charges. The hourly charge is fixed per gateway. The byte charge grows with traffic and is the one you can reduce. Don't confuse them when you compare months.
Exact usage type names change over time and differ by region, so confirm against your own data rather than relying on this table alone.
Using the console
In the Cost Explorer console, follow these steps.
- Open Cost Explorer and choose a date range that covers at least the last full month. Use daily granularity if you are hunting for a spike.
- Set Group by to Usage type.
- Add a filter on Usage type group. Groups such as "EC2: Data Transfer - Internet (Out)" and "EC2: Data Transfer - Inter AZ" collect related usage types so you do not need to list them yourself.
- Sort by cost and look at the top entries.
If you want to see which account or team is responsible, add a second grouping or filter by linked account. Grouping by a cost allocation tag works too, but only if the tag was activated in Billing before the charges occurred. Tags are not applied retroactively, which is why tagging is covered in a later chapter.
Using the CLI
The console is good for exploration. The CLI is better when you want a repeatable report. The command below lists last month's cost per usage type and keeps only data transfer and NAT gateway byte charges.
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 textA few points about this command.
- The
Enddate is exclusive.End=2026-11-01covers all of October. - The
--queryoption is a JMESPath expression that runs on the client after the API returns. It filters the output, but it does not reduce what Cost Explorer returns. The API call still groups everything by usage type. - Each Cost Explorer API request carries a charge, currently around one cent per call. Scripts that run often should cache results.
- The amount comes back as a string. Convert it before you sort numerically, or use
sort -k2 -n -ron the text output.
To rank the results, pipe the output through sort.
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 text | sort -k2 -n -r | head -10From usage type to cause
The usage type tells you the category, and the category narrows the fix. The flow below shows how to move from the largest line item to the next chapter or action.
Cost Explorer does not tell you which instance, subnet, or application produced the bytes. It reports cost, not source. That gap is why the next chapter uses VPC Flow Logs, which record the addresses and byte counts for individual flows.
Common mistakes
- Reading blended or net cost by accident. Use
UnblendedCostfor the raw charge, or amortized cost if you want reservations and savings plans spread out. Mixing them across reports produces numbers that do not match. - Comparing months of different length. A 31-day month has about 3% more traffic than a 30-day month. Compare daily averages when the differences are small.
- Ignoring the lag. Cost data can take up to 24 hours to appear. A change you made this morning will not show up yet.
- Missing credits and refunds. Credits and discounts can hide a growing transfer cost. Filter out record types such as Credit and Refund when you want to see the true usage trend.
- Filtering to one region. Inter-region traffic is attributed to the source region. If you filter to the destination region, you will miss it.
Building a baseline
Before you change anything, record a baseline. Save the top ten transfer usage types and their monthly cost, along with the date. After each optimization, rerun the same query and compare. Without a baseline, you can't show that a change worked, and you can't tell a real saving from normal month-to-month variation.
A simple approach is to write the CLI output to a dated file in a storage bucket or repository. Keep the exact command alongside it, so the query stays the same between runs.
Exercise
Your Cost Explorer view grouped by service shows "EC2-Other" as the second largest item. You suspect transfer costs. What do you do next, and what usage types would tell you the cost is from a NAT gateway rather than inter-AZ traffic?
Show answer
Filter to the EC2-Other service and regroup by usage type. NAT gateway costs appear as NatGateway-Bytes (traffic-driven) and NatGateway-Hours (fixed per gateway). Inter-AZ transfer appears as DataTransfer-Regional-Bytes. Comparing the cost of these entries shows which one dominates, and NatGateway-Bytes is the one that you can reduce with VPC endpoints or by changing traffic paths.
Exercise
A teammate runs the CLI command from this chapter with End=2026-10-31 and says October looks 3% cheaper than expected. What is wrong?
Show answer
The End date is exclusive, so End=2026-10-31 leaves out October 31. The report covers 30 of the 31 days. Use End=2026-11-01 to include the whole month.