← Back
petricbranko

petricbranko/awstree

Understand AWS billing

View on GitHub ↗
Stars
83
Forks
6
Watchers
83
Open issues
2
Contributors
1
Language
HTML
License
MIT License
Default branch
main
Created Sep 26, 2026Updated Sep 26, 2026

Star growth

Today—
This week—
This month—

Star history will appear here once this repo has been tracked for a couple of days.

README

awstree

Where did my AWS money go? awstree reads your AWS bill and draws it as a treemap: big box, big cost.

awstree showing a demo AWS bill as a treemap

It's one Python file with no dependencies to install, and it produces a single HTML page that works offline.

Quick start

git clone <this repo> && cd awstree
python3 awstree.py --demo                  # try it with fake data, no AWS needed
python3 awstree.py --profile my-profile    # your real bill

The page opens in your browser. It shows the last 30 days, compared with the 30 days before.

What you get

  • Treemap of spend by service → usage type. Press 2 to group by account and 3 to group by region.
  • Color by change (c): red where spend grew, green where it shrank.
  • Selection panel: cost, share of the bill, change vs the previous period, monthly pace and a daily chart.
  • Worth a look: the fastest-growing costs plus common money pits: NAT data processing, idle IPs, gp2 volumes, old snapshots, previous-gen instances and extended-support fees.
  • Export for AI: a JSON summary to hand to any AI agent (see below).

Click to select, double-click to zoom in, ⌫ to go back up, / to filter.

Requirements

  • Python 3.8+, plus the AWS CLI or boto3
  • Credentials with the ce:GetCostAndUsage permission. Run it from the management (payer) account to see every account in your organization.
  • Cost Explorer enabled in the Billing console. The very first time, it can take up to 24 hours before data shows up.

Cost: AWS charges $0.01 per Cost Explorer request, and a run makes about 4–10 requests. awstree saves the data, so reopening the page is free:

python3 awstree.py --from out/awstree-data.json

Ask an AI about your bill

python3 awstree.py --from out/awstree-data.json --export

This writes out/awstree-export.json, a compact summary (about 50 KB) that includes instructions for the agent. It has totals, breakdowns by service, account and region, every line item with its change vs the previous period, the top growers and the flagged money pits. Give it to an AI agent and ask "where can I save money?". The Export for AI button in the page (or e) downloads the same file.

Options

Flag What it does
--demo Fake data, no AWS access needed
--profile NAME AWS profile to use (SSO and aws login work)
--days N Period length, default 30. It's always compared with the period before it.
--metric M UnblendedCost (default), AmortizedCost, NetUnblendedCost, NetAmortizedCost
--from FILE Reopen saved data without calling AWS
--export [FILE] Write the AI summary JSON instead of the page
--out FILE Where to write the page (default out/awstree.html)
--no-open Don't open the browser

Privacy

awstree only reads from Cost Explorer and never changes anything in your account. Everything it writes goes to out/, which is git-ignored because it contains your account IDs and costs. The page loads nothing from the internet. Share the HTML or export file only with people who should see your bill.

Credits

Inspired by disktree by Tobi Lütke: the same idea, pointed at a cloud bill instead of a disk.

awstree is not affiliated with or endorsed by Amazon Web Services.

License

MIT