By the end you'll know
- How to see where an account's money went, by service and by day
- What unblended cost, credits and record types mean on a bill
- What "EC2 - Other" hides, and why it's often the biggest line
- How cost allocation tags turn your own tags into bill lines
- How to set a budget that warns before the spending, and the setting that makes it lie
- How Savings Plans and Reserved Instances trade commitment for a discount
Before you start
- You need: the
juniper-ryeprofile, signed in, and Lesson 20's virtual environment. Lesson 1 covers how the bill works, and Lesson 2 set the budget this lab finds. - The script:
lab.pyfrom the practice folder'slesson-37. It reads the bill and creates one budget, namedjr-lesson37-monthly, which itsdeletestep removes. - Where you run things: your own machine, labeled (Your machine).
- Every output below is from real runs on November 16, 2026, at about 4:40pm in New York, which is 9:40pm UTC. The numbers are this account's real costs.
The Cost Explorer page is free; its API isn't
Every Cost Explorer API request costs $0.01, and each page of results is a request. The same data in the console costs nothing. This lab made 6 requests, $0.06. A dashboard that refreshes every minute would make 43,200 a month. Ask for exactly the data you need, monthly rather than daily where you can, and cache it.
The short version
- Cost Explorer shows where the money went, by service, day, Region, tag or account.
- Unblended cost is the price of what you used; credits and refunds are separate record types.
- "EC2 - Other" is everything EC2 that isn't an instance: volumes, snapshots, NAT gateways, addresses, data transfer.
- Cost allocation tags make your own tags into bill lines, once activated.
- A budget warns before you spend, and must exclude credits or it says nothing while credits pay.
- Savings Plans and Reserved Instances discount steady usage in exchange for a one- or three-year commitment.
What this lesson costs
| Part | Price | This lab |
|---|---|---|
| Cost Explorer API requests | $0.01 each | 6, $0.06 |
| The account plan, prices and budgets | Free to read | Nothing |
| A budget without actions | Free | Nothing |
| This lesson | $0.06, from credits |
Where the money went
(Your machine)
cd ~/Apps/aws-practice/lesson-37
source ../lesson-20/.venv/bin/activate
python lab.py fence
== The account plan (free to ask)
plan FREE, status ACTIVE
credits left: 179.36 USD
plan ends: 2027-05-09, in 174 days
== What the Cost Explorer API costs (from the Price List API)
$0.01 $0.01 per Request for AdditionalSourceViews in US East (N. Virginia)
$0.01 $0.01 per API Request
$0.00001 $0.01 per 1,000 UsageRecord-month of stored Granular Cost Data Usage-records
== Budgets already set: 2
jr-lesson37-monthly: 10.0 USD a monthly
monthly-10-usd: 10.0 USD a monthly
- The free plan, read by script, for free.
get_account_plan_stategives the plan, the credits left, and the end date: six months after the account was opened, or sooner if the credits run out. This account earned $180 in credits; $179.36 are left. - The Cost Explorer API's own price is in the price list, like everything else. The third line is hourly and resource-level detail, an optional extra.
- Two budgets.
monthly-10-usdis the one Lesson 2 set up on day one. The other was made by this lab'sbudgetstep, run before this rerun offence; more on that below. (The script printed "a monthly" here; it now prints "monthly".)
The whole track: $0.64
python lab.py spend
== Cost by month and service, 2026-08-01 to today (UnblendedCost, before credits)
service 2026-08 2026-09 2026-10 2026-11
EC2 - Other $ 0.00 $ 0.00 $ 0.00 $ 0.34
Amazon Elastic Load Balancing $ 0.00 $ 0.00 $ 0.00 $ 0.12
Amazon Elastic Container Service for Kubernete $ 0.00 $ 0.00 $ 0.00 $ 0.06
Amazon Virtual Private Cloud $ 0.00 $ 0.00 $ 0.00 $ 0.04
Amazon Relational Database Service $ 0.00 $ 0.00 $ 0.00 $ 0.03
Amazon Elastic Compute Cloud - Compute $ 0.00 $ 0.00 $ 0.00 $ 0.02
Amazon Simple Storage Service $ 0.00 $ 0.00 $ 0.00 $ 0.01
Amazon Elastic Container Service $ 0.00 $ 0.00 $ 0.00 $ 0.01
(22 more services, under half a cent each)
total $ 0.00 $ 0.00 $ 0.00 $ 0.64
== The same months by record type: what was used, and what credits paid
2026-08: nothing; you paid $ 0.00
2026-09: nothing; you paid $ 0.00
2026-10: nothing; you paid $ 0.00
2026-11: Credit $ -0.64, Usage $ 0.64; you paid $ -0.00
(2 Cost Explorer requests, $0.02)
Thirty services were used, and $0.64 is the whole bill for every lab in this track: EC2, load balancers, RDS, EFS, Lambda, ECS, EKS and the rest. The account was opened in November, so the earlier months are empty. Every lab created what it needed, measured it, and deleted it the same day, and that habit is most of cost management.
Read the order of the lines, not just the total:
- "EC2 - Other" is the biggest line, at more than half. It's everything billed under EC2 that isn't an instance's running time: EBS volumes and snapshots, NAT gateways, Elastic IP addresses, and data transfer. It's the line that grows quietly in real accounts, because a stopped instance stops its compute charge but not its volume's, and a NAT gateway charges by the hour whether anything uses it or not.
- Load balancers are second, at $0.12, more than the instances behind them. A load balancer charges by the hour from the moment it exists.
- EKS's $0.06 is mostly the control plane, at $0.10 an hour: Lesson 29's cluster existed for about half an hour.
- Compute, the instances themselves, is only $0.02. Small, short-lived instances are cheap; what surrounds them often isn't.
Unblended cost is the price of each thing used, at the rate you paid for it. Record types keep different kinds of line apart: Usage is what you used, Credit is credits paying for it, and there are others for refunds, taxes and Savings Plan fees. Net cost is what's left: here, -0.00, which is zero after rounding. A view that mixes record types without saying so will tell you the free plan costs nothing, which is true of what you paid and false of what you used.
Day by day
python lab.py daily
== The last 30 days, day by day (usage before credits)
2026-10-17 $ 0.00
…
2026-11-09 $ 0.00
2026-11-10 $ 0.27 ########################################
2026-11-11 $ 0.16 ########################
2026-11-12 $ 0.00
2026-11-13 $ 0.01 #
2026-11-14 $ 0.00
2026-11-15 $ 0.19 ############################
30 days: $ 0.63; the most in one day: $ 0.27 on 2026-11-10
== AWS's forecast for the rest of this month (usage before credits)
DataUnavailableException: Insufficient amount of historical data.
(1 Cost Explorer request, $0.01)
The 23 empty days before November 10 are shortened here.
- Three days hold almost everything. Going by when those lessons were written, November 10 and 11 were the load balancer, high availability, storage and RDS labs, and November 15 was ECS, Terraform and EKS. A daily view is how you match spending to what happened: here it's labs, in a company it's a deploy, a test that didn't clean up, or a traffic spike.
- Today isn't there. Cost Explorer's data runs about a day behind, so the day you're in, and sometimes yesterday, are incomplete. Don't judge today's spending from today's view.
- The forecast refused: not enough history. AWS forecasts from past patterns, and an account with three busy days in a week of history hasn't got one. On a steady account, the forecast is what budgets use to warn you before the month ends.
Tags that become bill lines
Every lab in this track tagged what it made: lesson=27, owner=juniper-rye. In a company, tags like team, project and environment answer the question finance always asks: whose is this? But the bill doesn't group by your tags on its own. A tag has to be activated as a cost allocation tag in the account that pays the bill, then it shows up as a dimension in Cost Explorer, about a day later, for spending from then on. AWS can also backfill an activated tag up to a year into the past.
The plan was to activate lesson, backfill it, and show cost per lesson the next day.
python lab.py tags
== Cost allocation tags: user tags this account has used
AWS said: An error occurred (AccessDeniedException) when calling the ListCostAllocationTags operation: Failed to list Cost Allocation Tags: Linked account doesn't have access to cost allocation tags.
"Linked account" is the clue to this whole track. Cost allocation tags are managed by the account that pays the bill. In an organization, that's the management account, and every other account is a linked account that can't touch them. So this free-plan account is evidently a linked account in an organization it didn't create.
That fits everything else. Service control policies only exist inside organizations, and since Lesson 33 this account has hit "explicit deny in a service control policy" on GitHub sign-in sources, GuardDuty, Security Hub, and below, Savings Plan prices. AWS doesn't describe how the free plan is built, so take this as an inference from the errors, not a documented fact: a free-plan account appears to sit in an organization AWS runs, whose policies keep it inside the free plan's limits.
On a paid-plan account, or as an organization's management account, you'd activate the tag in the Billing console under Cost allocation tags, or with update_cost_allocation_tags_status, and group by it a day later. The script's tags and bylesson steps do exactly that, for anyone who can.
A budget that warns first
A budget compares spending with a limit and emails or notifies when it crosses a threshold, on actual spending, or on the forecast, which can warn before the money's gone. Budgets without actions are free; budgets that act, like applying a restrictive policy when exceeded, are free for the first two.
python lab.py budget
== Created budget jr-lesson37-monthly: $10 a month, counting usage before credits
warnings: none (set BUDGET_EMAIL=you@example.com and run budget again after delete)
so far this month: actual not calculated yet, forecast not calculated yet
budgets without actions are free; this one has none
- "Counting usage before credits" is the setting that matters most on a credit-funded account. The script sets
IncludeCreditto false. With credits included, spending is offset to zero, and a budget measuring zero never warns, right up to the day the credits run out. - No warnings were set, because no email was given. A budget with no notification is a number nobody sees: give it an email address or an SNS topic.
- "Not calculated yet": budgets update a few times a day, and a new one shows its first figures within a day.
This account already had a budget, from Lesson 2, so this one is a duplicate, and delete removes it below. Lesson 2's is the one to keep.
Savings Plans and Reserved Instances
Everything so far has been on-demand: pay by the second or hour, stop any time. For usage that's steady, AWS gives a discount for committing in advance:
- Savings Plans: commit to spending a fixed amount an hour, say $0.50, for one or three years. Usage up to that amount is billed at the lower rate; anything above it is on-demand. Compute Savings Plans apply to EC2 of any type in any Region, Fargate and Lambda; EC2 Instance Savings Plans give more discount for committing to one instance family in one Region.
- Reserved Instances: the older form, a commitment to a specific instance type, still the way to discount RDS, ElastiCache, Redshift and OpenSearch.
- Spot: spare capacity at a large discount that AWS can take back with two minutes' notice, for work that can be interrupted.
The more you commit (three years instead of one, paid upfront instead of monthly, one family instead of any), the bigger the discount.
python lab.py savings
== A t4g.small in us-east-2: on-demand, against a Compute Savings Plan (free price lookups)
on-demand: $0.0168 an hour, $12.26 a month
Savings Plan rates: AccessDeniedException: User: (an ARN) is not authorized to perform: savingsplans:DescribeSavingsPlansOfferingRates on resource: (an ARN) with an explicit deny in a service control policy: (an A
== What AWS recommends for this account (a 1-year Compute Savings Plan, no upfront, from the last 30 days)
no recommendation: {}
(1 Cost Explorer request, $0.01)
- On-demand, a t4g.small is $0.0168 an hour, $12.26 for a month left running.
- Savings Plan rates were refused, even just to read: the free plan's organization again. On a paid account, this step prints the hourly rate for one- and three-year plans next to the on-demand price.
- AWS recommended nothing, correctly. Recommendations look for usage that runs steadily, hour after hour; this account runs things for minutes and deletes them. Committing to $0.10 an hour here would pay for 8,760 hours a year to cover a few. (The script printed the empty reason as
{}; it now says so in words.)
The rule of thumb: commit to the floor, not the peak. Look at the lowest hourly spend over the last few months, commit to about that, and leave everything above it on-demand.
Take it down
python lab.py delete
== Deleted budget jr-lesson37-monthly
== What Lesson 37 left
budget jr-lesson37-monthly: gone
the lesson and owner cost allocation tags stay active: free, and they keep cost per lesson working
The last line is wrong for this account: the tags were never activated, because tags was refused. The script assumed tags had worked; it now checks instead of assuming. Nothing else was created, and Lesson 2's budget is untouched.
By hand: the same with the AWS CLI
(Your machine) Each ce command is one $0.01 request:
export AWS_PROFILE=juniper-rye
aws freetier get-account-plan-state
aws ce get-cost-and-usage --time-period Start=2026-11-01,End=2026-11-16 --granularity MONTHLY --metrics UnblendedCost --group-by Type=DIMENSION,Key=SERVICE --filter '{"Dimensions":{"Key":"RECORD_TYPE","Values":["Usage"]}}'
aws ce get-cost-and-usage --time-period Start=2026-11-01,End=2026-11-16 --granularity DAILY --metrics UnblendedCost
A free budget with an email warning at 80% of actual spend:
ACCOUNT=$(aws sts get-caller-identity --query Account --output text)
aws budgets create-budget --account-id $ACCOUNT --budget '{"BudgetName":"by-hand","BudgetType":"COST","TimeUnit":"MONTHLY","BudgetLimit":{"Amount":"10","Unit":"USD"},"CostTypes":{"IncludeCredit":false}}' --notifications-with-subscribers '[{"Notification":{"NotificationType":"ACTUAL","ComparisonOperator":"GREATER_THAN","Threshold":80,"ThresholdType":"PERCENTAGE"},"Subscribers":[{"SubscriptionType":"EMAIL","Address":"you@example.com"}]}]'
aws budgets delete-budget --account-id $ACCOUNT --budget-name by-hand
In real systems
- A tagging policy, enforced with tag policies and Config rules, so every resource says whose it is, and the tags are activated for cost allocation in the management account.
- Budgets per team or project, filtered by tag, with warnings at 50%, 80% and 100% of the forecast, sent where the team will see them.
- Cost Anomaly Detection, a free service that learns normal spending and alerts on a sudden jump, like a forgotten GPU instance.
- Data Exports (the Cost and Usage Report) for line-by-line detail, queried with Athena, and dashboards built on it.
- Rightsizing first, commitments second: Compute Optimizer finds oversized instances, and Savings Plans only cover what's left after.
- Non-production turned off at night and at weekends, with schedules, because 128 hours a week of an idle test environment is most of its bill.
Spot the problem
Work out what's wrong before you read the explanation.
"The budget never said a word." A startup gets $5,000 of credits, and sets a $1,000-a-month budget with email warnings. Months pass with no alerts. When the credits run out, the first real bill is $3,800 for the month. What's wrong? The budget included credits, so it measured spending after credits, which was zero every month until they were gone: it was working correctly, on the wrong number. The fix: set the budget to exclude credits, so it measures what was used, and warn on the forecast as well as the actual. Then check: the budget's actual spend should match Cost Explorer's usage for the month, not the zero on the invoice.
Keep this
| Remember | Why |
|---|---|
| Cost Explorer's API is $0.01 a request | The console is free; pages count |
| Read usage and credits apart | Net cost hides what was used |
| "EC2 - Other" grows quietly | Volumes, NAT gateways, addresses, transfer |
| Cost data runs a day behind | Don't judge today from today |
| Activate tags for cost allocation | In the paying account; a day to appear |
| Budgets: exclude credits, warn on forecast | Or they're silent until it's too late |
| Commit to the floor, not the peak | Savings Plans cover steady usage only |
| Create, measure, delete | Why this whole track cost $0.64 |
Where you are now
Juniper & Rye's bill has been read line by line: $0.64 for the whole track, more than half of it the quiet "EC2 - Other", nearly all of it on three lab days, and every cent paid by credits, with $179.36 of them left. The lesson tag couldn't become a bill line here, and that refusal explained the free plan's organization and every explicit deny before it. A budget now knows the difference between what's used and what's paid. Next, Lesson 38 steps back and reviews everything built in this track against the Well-Architected Framework.
Check yourself
What does each Cost Explorer API request cost?
Which of these would appear under 'EC2 - Other'?
November's usage was $0.64 and the net was $0.00. Why?
Why did listing cost allocation tags fail?
A budget includes credits, and credits pay everything. What does it warn about?
Why did AWS recommend no Savings Plan?
How much should a first Savings Plan commit to?
Key terms
- Cost Explorer: AWS's tool for viewing and querying cost and usage, free in the console and $0.01 a request by API.
- Unblended cost: the cost of each item at the rate actually charged for it.
- Net cost: cost after credits, refunds and discounts.
- Record type: the kind of bill line: Usage, Credit, Refund, Tax and others.
- EC2 - Other: EC2's charges that aren't instance hours: volumes, snapshots, NAT gateways, Elastic IPs, data transfer.
- Cost allocation tag: a tag activated in the paying account so the bill can be grouped by it.
- Management account / linked account: the account that pays an organization's bill, and the accounts it pays for.
- Budget: a limit on cost or usage that notifies at thresholds of actual or forecast spending.
- Savings Plan: a one- or three-year commitment to an hourly spend, in exchange for lower rates.
- Reserved Instance: a commitment to a specific instance type, the older form of the same idea.
- Spot: spare capacity at a discount, which AWS can reclaim.
Go deeper
- Earlier lessons: What AWS solves, and how the bill works, A safe account for the first budget, and An unused-resource checker for finding what's still running.
- AWS: Analyzing your costs with Cost Explorer (opens in a new tab), and Using cost allocation tags (opens in a new tab).
- AWS: Managing your costs with AWS Budgets (opens in a new tab), and What are Savings Plans? (opens in a new tab)
- AWS: Cost Explorer pricing (opens in a new tab), and Budgets pricing (opens in a new tab).
- Try: open Cost Explorer in the console and build the same service-by-month view for free. Then change Lesson 2's budget to exclude credits, if it doesn't already.