AWS from zero · Part 6: Operating, securing and governing · Lesson 37 of 38 · about 35 minutes

Cost management: tags, Cost Explorer and Savings Plans

Thirty-six lessons of real AWS, from EC2 to EKS, cost $0.64, and this lab found out exactly where it went: by service, by day, and against the credits that paid it. Then a budget that warns before money is spent, and what Savings Plans would save. Two of the tools refused on this free-plan account, and the refusal turned out to explain every 'explicit deny' in the track.

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-rye profile, 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.py from the practice folder's lesson-37. It reads the bill and creates one budget, named jr-lesson37-monthly, which its delete step 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

PartPriceThis lab
Cost Explorer API requests$0.01 each6, $0.06
The account plan, prices and budgetsFree to readNothing
A budget without actionsFreeNothing
This lesson$0.06, from credits

Where the money went

Cost Explorer is the bakery's ledger, read by category. At the end of the month the accountant doesn't just say "we spent $3,000"; she says flour was $1,200, gas for the ovens $400, and the delivery van's fuel doubled in the second week. Juniper & Rye's AWS bill works the same way, and the question is always the same: which line grew, and when?

(Your machine)

BASH
cd ~/Apps/aws-practice/lesson-37
source ../lesson-20/.venv/bin/activate
python lab.py fence
OUTPUT
== 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_state gives 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-usd is the one Lesson 2 set up on day one. The other was made by this lab's budget step, run before this rerun of fence; more on that below. (The script printed "a monthly" here; it now prints "monthly".)

The whole track: $0.64

BASH
python lab.py spend
OUTPUT
== 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.

The whole track's cost by service, November 2026Usage before credits: EC2 - Other $0.34, Elastic Load Balancing $0.12, EKS $0.06, VPC $0.04, RDS $0.03, EC2 compute $0.02, S3 $0.01, ECS $0.01. Thirty services in all came to $0.64, all paid by credits.EC2 - Other$0.34Elastic Load Balancing$0.12EKS$0.06VPC$0.04RDS$0.03EC2 compute$0.02S3$0.01ECS$0.0130 services in all, $0.64; the other 22 were under half a cent each.
More than half the bill was "EC2 - Other", and the instances themselves were two cents.

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

BASH
python lab.py daily
OUTPUT
== 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.

BASH
python lab.py tags
OUTPUT
== 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.

BASH
python lab.py budget
OUTPUT
== 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 IncludeCredit to 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.

BASH
python lab.py savings
OUTPUT
== 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

BASH
python lab.py delete
OUTPUT
== 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:

BASH
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:

BASH
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

RememberWhy
Cost Explorer's API is $0.01 a requestThe console is free; pages count
Read usage and credits apartNet cost hides what was used
"EC2 - Other" grows quietlyVolumes, NAT gateways, addresses, transfer
Cost data runs a day behindDon't judge today from today
Activate tags for cost allocationIn the paying account; a day to appear
Budgets: exclude credits, warn on forecastOr they're silent until it's too late
Commit to the floor, not the peakSavings Plans cover steady usage only
Create, measure, deleteWhy 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

  1. What does each Cost Explorer API request cost?

  2. Which of these would appear under 'EC2 - Other'?

  3. November's usage was $0.64 and the net was $0.00. Why?

  4. Why did listing cost allocation tags fail?

  5. A budget includes credits, and credits pay everything. What does it warn about?

  6. Why did AWS recommend no Savings Plan?

  7. 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