Nothing in AWS has a price tag you pay once. You pay for what exists and for what you call, metered continuously. A machine costs by the hour whether anyone uses it. A gigabyte in a bucket costs by the month. A request costs a fraction of a cent. The bill is the sum, and it never stops.
What costs money
| Costs while it exists | Costs when used | Free |
|---|---|---|
| instances, databases, NAT gateways, load balancers, unattached Elastic IPs, stored data | requests, data transfer out, function invocations | empty buckets, security groups, most configuration |
The right column is small. The left column is where surprises live: something created for a test and never deleted. The free tier covers a modest amount of several services during an account's first year. Treat it as a discount, not as free: everything in the left column still needs deleting when you are done with it.
Reading the bill
aws ce get-cost-and-usage \
--time-period Start=$(date +%Y-%m-01),End=$(date -d tomorrow +%F) \
--granularity MONTHLY --metrics UnblendedCostCost Explorer wants a period, a granularity (DAILY or MONTHLY) and a metric. UnblendedCost is the plain price of what you used. Add --group-by Type=DIMENSION,Key=SERVICE to see which services the money went to. Right now the market is a bucket with three small files; the amount has several zeros after the decimal point. It is still a real number, and it grows as the course adds instances.
A budget
aws budgets create-budget --account-id 123456789012 \
--budget file://budget.json --notifications-with-subscribers file://alert.json
aws budgets describe-budget --account-id 123456789012 --budget-name market-monthlybudget.json names the budget, a limit (5 USD), MONTHLY and COST. alert.json says who to tell when actual spend passes 80 per cent of it. A budget alerts; it does not switch anything off. Every account in this course gets one in its first hour, because the first surprise bill is the one that hurts.