Sub topic 2
Where the money goes: compute, storage and data transfer
This chapter assumes you know the basics of EC2, S3, EBS and VPC networking, can run AWS CLI commands, and can read JSON. It builds on the usage-based pricing model from the previous chapter. Here you learn which services usually produce the largest charges and how to find the biggest ones in your own account.
The three cost families
Almost every AWS bill is a mix of three families. Each one bills a different unit.
| Family | Typical services | What you pay for | Common surprise |
|---|---|---|---|
| Compute | EC2, Lambda, Fargate, RDS instances | Time running, or requests and duration | Instances left running with no load |
| Storage | S3, EBS, EFS, snapshots | GB stored per month, plus requests | Unattached volumes and old snapshots |
| Data transfer | Internet egress, cross-AZ, cross-Region, NAT gateways | GB moved | Traffic between Availability Zones |
Compute
Compute is billed for the time a resource exists, not for how busy it is. An EC2 instance at 2 percent CPU costs the same per hour as one at 90 percent. This is why oversized and idle instances are the first place to look. Serverless services such as Lambda bill per request and per millisecond of duration, so cost follows actual use.
Storage
Storage is billed for capacity provisioned or stored, per GB-month. An EBS volume bills for its full size whether or not it holds data, and it keeps billing after the instance is terminated if it was not set to delete on termination. S3 bills for the bytes stored, the storage class, and the number of requests.
Data transfer
Data entering AWS is mostly free. Data leaving is not. You are charged for traffic to the internet, between Regions, and between Availability Zones. A NAT gateway adds an hourly charge plus a per-GB processing charge on everything that passes through it. Data transfer is easy to miss because it has no resource of its own. It appears as usage lines spread across other services.
How a request becomes a cost
A single request can add compute time, storage reads, and several transfer charges. Cost control starts by knowing which of these dominates for your workload.
Finding your largest drivers
Ask Cost Explorer for one month of spend grouped by service. This command returns October 2026 unblended cost:
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=SERVICEThe End date is exclusive, so this covers all of October. Each entry in ResultsByTime[].Groups[] shows a service name and its amount. Sort mentally from the top: in many accounts, EC2, S3, RDS and data transfer lines account for most of the total.
To split a service further, group by USAGE_TYPE. Data transfer shows up there with names that contain DataTransfer or NatGateway, which lets you separate transfer from the compute and storage of the same service.
Common mistakes
- Reading only the service name. EC2 charges include instance hours, EBS volumes, and data transfer, so "EC2" is not just compute.
- Ignoring small hourly charges. A resource at a few cents per hour costs several dollars a month, and many of them add up.
- Looking at one day. Monthly granularity hides spikes and daily granularity hides trends, so check both.
- Forgetting that stopped instances still pay for their attached EBS volumes.
Exercise
An EC2 instance is stopped for a month. Which of its costs stop, and which continue?
Show answer
Instance compute hours stop while it is stopped. Charges for attached EBS volumes continue, because storage is billed for provisioned capacity. Any Elastic IP address that stays allocated may also incur charges.
Exercise
Which Cost Explorer grouping would you add to the command above to separate NAT gateway data processing from the rest of your EC2-related spend?
Show answer
Group by USAGETYPE (Key=USAGETYPE). Usage types containing NatGateway identify the NAT gateway hourly and per-GB charges separately from instance hours and volume storage.