The bill is one number until you make it talk
AWS's invoice arrives as a total. When it jumps from $80 to $310, the number itself tells you nothing: which team, which project, which forgotten experiment? Companies lose real money to exactly this opacity, and "why did the bill go up" lands on an engineer — often a junior one — every single month. This lesson is the toolkit for answering it in minutes instead of an afternoon.
Three tools, all free:
- Tags are key-value labels you attach to any resource at creation:
project=api,team=growth,env=staging. Once a tag key is activated for cost allocation, every line of spending carries the label. - Cost Explorer is the console's bill browser: it charts spending over time and, crucially, groups by tag or by service, turning the one number into a breakdown.
- AWS Budgets sends alerts when actual or forecasted spend crosses a threshold you set. The billing alarm from lesson 8-2 was the minimal version; budgets are the same idea with per-project scoping.
Code exercise · bash
What Cost Explorer does with cost-allocation tags, in miniature: take every charge with its project tag and print a per-project table. Run it. The amounts are cents per month, and the format string %-9s left-pads each project name to 9 characters so the dollars line up.
The untagged problem
That untagged line is the classic failure: resources created in a hurry carry no labels, so their cost belongs to nobody, and unowned spending is exactly the spending nobody turns off. The fixes teams actually use: agree on 2-3 mandatory tag keys, bake them into every deployment template so nothing is created by hand, and review the untagged bucket in Cost Explorer monthly until it shrinks toward zero.
Two more habits close the loop:
- A budget per project with an alert at, say, 80% of the expected spend. Forecast-based alerts fire before the money is gone: AWS extrapolates the month's spending rate and warns when the projection crosses your line.
- A weekly two-minute Cost Explorer glance, grouped by service. A NAT gateway (lesson 5-2) quietly processing terabytes, or a forgotten instance (lesson 8-2's trap 1), shows up as a line that grew when nothing shipped.
Code exercise · bash
Your turn. Finish the audit script: total every project's cents, and record the untagged amount when the loop passes it (the tag name to match is the string untagged). Print the total bill line and the untagged share, matching the expected output exactly.
Quiz
On the 10th of the month, a $50 budget alert fires even though only $21 has actually been spent. Is the alert broken?