Skip to main content

awsce

Check, summarize and analyze your AWS costs from the command line.

ci security OpenSSF Scorecard License: MIT

Why

The AWS console is slow when you only want a quick answer:

  • What did we spend this month, and on which services?
  • Which usage type inside EC2 costs the most?
  • How do five accounts compare, side by side?
  • Where can we save money right now?

awsce answers these from your terminal, using the AWS credentials you already have. When you need to share the answer, it exports CSV, JSON or a self-contained HTML report.

Install

Requires Python 3.10 or newer.

pipx install awsce        # or: pip install awsce
awsce --version

From source:

git clone https://github.com/hoangbeard/awsce.git
cd awsce
pip install -e .

Quick start

# This month so far, for your default profile
awsce costs

# Last month, saved as an HTML report
awsce costs --start 2026-09-01 --end 2026-10-01 -o september.html

# Compare several accounts, grouped by service
awsce costs -p dev -p staging -p prod --view services

# Where can we save money?
awsce optimize rightsizing -r us-east-1 -r eu-west-1
awsce optimize hub

Commands

Command What it does
awsce costs Costs by service and usage type, for one or more accounts
awsce services AWS services that had cost or usage in a period
awsce cost-category NAME Costs grouped by an AWS Cost Category, then by service
awsce optimize rightsizing Rightsizing recommendations from AWS Compute Optimizer
awsce optimize hub Savings recommendations from AWS Cost Optimization Hub
awsce cache list / clear Look at or remove cached results

Run any command with --help to see all options.

Periods

--start is the first day. --end is the day after the last day, the same way Cost Explorer works. So --start 2026-09-01 --end 2026-10-01 is all of September.

With no dates, awsce shows the current month so far. On the 1st of a month, it shows last month instead.

Many accounts

Use one profile per account:

awsce costs -p dev -p prod              # chosen profiles
awsce costs --all-profiles              # every profile in ~/.aws/config

Then pick how to see them with --view:

View Shows
accounts (default) Each account on its own
services Each service, with what every account spends on it
summary Each usage type across all accounts, with total usage and average unit price

If one profile fails, for example an expired SSO session, awsce warns you and goes on with the rest.

If you use AWS Organizations, you can also run awsce costs once with the management account. Cost Explorer there already includes every member account.

Small amounts

Rows under $0.01 are hidden by default to keep the output short. Totals always include them. Add --detail to see every row. Credits and refunds (negative amounts) are always shown.

Export

Add -o FILE. The format follows the extension:

Extension Content
.csv One row per usage type, ready for a spreadsheet
.json The full data, for scripts
.html A report with charts that you can open in any browser or send by email (costs and cost-category only)

Savings recommendations

# Compute Optimizer: EC2, Auto Scaling, EBS, Lambda, RDS, ECS on Fargate
awsce optimize rightsizing -r us-east-1 --type ec2 --type ebs --min-savings 10

# Every member account, from the management account
awsce optimize rightsizing -p management --organization

# Cost Optimization Hub: rightsizing, Savings Plans, Reserved Instances and more
awsce optimize hub --type Ec2Instance --limit 20

Both services must be turned on in your account first: Compute Optimizer and Cost Optimization Hub.

Cost and caching

Cost Explorer charges $0.01 for each API request. To keep this low, awsce caches results on your machine:

Data Cached for
Costs and cost categories 24 hours
Recommendations 4 hours

Use --refresh to skip the cache, or --cache-hours to change how long it lasts. The cache lives in ~/.cache/awsce (or $AWSCE_CACHE_DIR).

Permissions

awsce only reads. A minimal IAM policy:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Costs",
      "Effect": "Allow",
      "Action": ["ce:GetCostAndUsage", "ce:GetDimensionValues"],
      "Resource": "*"
    },
    {
      "Sid": "Recommendations",
      "Effect": "Allow",
      "Action": [
        "compute-optimizer:GetEC2InstanceRecommendations",
        "compute-optimizer:GetAutoScalingGroupRecommendations",
        "compute-optimizer:GetEBSVolumeRecommendations",
        "compute-optimizer:GetLambdaFunctionRecommendations",
        "compute-optimizer:GetRDSDatabaseRecommendations",
        "compute-optimizer:GetECSServiceRecommendations",
        "cost-optimization-hub:ListRecommendations",
        "organizations:ListAccounts"
      ],
      "Resource": "*"
    }
  ]
}

Compute Optimizer also needs read access to the resources it reports on. The AWS managed policy ComputeOptimizerReadOnlyAccess covers this.

Security notes

  • awsce never writes to your AWS account.
  • Credentials come from the normal AWS chain (profiles, SSO, environment variables). awsce never stores them, and error output never prints them.
  • Cache files hold account IDs and cost data. They are readable only by you (mode 600).
  • HTML reports escape every name that comes from AWS. CSV exports guard against spreadsheet formula injection.
  • HTML reports load Chart.js from a CDN, pinned with a Subresource Integrity hash.

Development

python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pre-commit install

pytest              # tests use botocore Stubber, no AWS account needed
ruff check . && ruff format --check .
mypy src

License

MIT © Pham Huy Hoang (HoangBeard)

Metadata

Release files for awsce 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for awsce 0.1.0
File Size Uploaded
awsce-0.1.0.tar.gz 29.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for awsce 0.1.0
File Interpreter ABI Platform
awsce-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 57.6 kB

Release files / awsce-0.1.0.tar.gz

Download URL awsce-0.1.0.tar.gz
Size 29.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e1c3f7c37095ed575eac1730305d547d5602a4cf6aaa206c118c9dde8b395e02
BLAKE2b-256 checksum
How to use checksums
1ef03eaf0ddc485163c1884d425267897d8bcfadcacb0d69c52ac513870d0140
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release files / awsce-0.1.0-py3-none-any.whl

Download URL awsce-0.1.0-py3-none-any.whl
Size 27.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
25932c23ca21074811037ec96b6aded0499745252d8f5eb8ed7daf41b681b1ba
BLAKE2b-256 checksum
How to use checksums
b0cf37924aa9bfe5c1f518dd587a8c5cf239cfc0008c59490bd2d2311a27b723
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page