Skip to main content

A CLI tool to analyze and monitor your AWS spending

Project description

aws-cost-cli

A command-line tool for analyzing AWS spend across services, regions, accounts, and tags — with forecasting, anomaly detection, budget tracking, and Slack notifications.

CI Python License Docker


Commands

Command What it does
summary Monthly totals for the last N months
daily Day-by-day breakdown for any period
services Cost by AWS service
regions Cost by AWS region
accounts Cost by linked account (AWS Organizations)
tags Cost by resource tag key
compare Side-by-side with the previous equivalent period
forecast Projected spend for the rest of this month or year
anomalies Unusual spend spikes detected by AWS
budget set/list/status Set monthly budgets and track usage
notify slack Send a cost summary to a Slack channel
watch Live-refresh cost view in the terminal

Install

From source (recommended while in early development)

git clone https://github.com/Mide69/aws-cost-cli.git
cd aws-cost-cli
pip install -e .

With Docker (no Python required)

docker pull tektribe/aws-cost-cli:latest

docker run --rm \
  -e AWS_ACCESS_KEY_ID \
  -e AWS_SECRET_ACCESS_KEY \
  -e AWS_DEFAULT_REGION \
  tektribe/aws-cost-cli services

Prerequisites

  • AWS credentials configured (see Authentication)
  • Cost Explorer enabled in your AWS account: AWS Console → Billing → Cost Explorer → Enable (takes up to 24 hours to activate on a new account)

Usage

Time periods

All commands accept --period with the following values:

Flag Range
yesterday Previous calendar day
7d Last 7 days
30d Last 30 days
mtd Month to date (default)
last-month Previous full calendar month
3m Last 3 months
6m Last 6 months
ytd Year to date
2026-03 Specific month (YYYY-MM)
--start / --end Fully custom date range

Examples

# Monthly overview
aws-cost summary
aws-cost summary --months 12

# Daily spend last week
aws-cost daily --period 7d

# Services this month, top 10 only
aws-cost services --top 10

# Services last month vs the month before
aws-cost services --period last-month --compare

# Which regions are costing the most?
aws-cost regions --period ytd

# Break down cost by your Environment tag
aws-cost tags --tag-key Environment

# Full comparison report (services, ranked by change)
aws-cost compare --period last-month --by SERVICE

# Forecast: how much will this month cost?
aws-cost forecast

# Anomalies in the last 14 days above $5 impact
aws-cost anomalies --days 14 --threshold 5

# Set a monthly budget and check it
aws-cost budget set total 500
aws-cost budget set "Amazon EC2" 200
aws-cost budget status

# Send a Slack report
export AWS_COST_SLACK_WEBHOOK=https://hooks.slack.com/services/...
aws-cost notify slack --period last-month

# Export to CSV
aws-cost --format json services > services.json
aws-cost --format csv services > services.csv

# Live view, refreshes every 30 seconds
aws-cost watch --interval 30

# Use a named AWS profile
aws-cost --profile production services

Authentication

The tool uses the standard AWS credential chain — no custom credential flags needed:

  1. Environment variables: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
  2. AWS credentials file: ~/.aws/credentials
  3. AWS config file: ~/.aws/config
  4. IAM role (EC2, ECS, Lambda, etc.)

To configure credentials:

aws configure

IAM Permissions

Minimum permissions required:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ce:GetCostAndUsage",
        "ce:GetCostForecast",
        "ce:GetAnomalies"
      ],
      "Resource": "*"
    }
  ]
}

Cost Explorer charges ~$0.01 per API request.


Docker

Pull from Docker Hub:

docker pull tektribe/aws-cost-cli:latest

Run with environment variable credentials:

docker run --rm \
  -e AWS_ACCESS_KEY_ID \
  -e AWS_SECRET_ACCESS_KEY \
  -e AWS_DEFAULT_REGION=us-east-1 \
  tektribe/aws-cost-cli services --period last-month --compare

Run with a mounted credentials file:

docker run --rm \
  -v ~/.aws:/root/.aws:ro \
  tektribe/aws-cost-cli summary

Build locally from source:

docker build -t tektribe/aws-cost-cli .

Development

git clone https://github.com/Mide69/aws-cost-cli.git
cd aws-cost-cli

python -m venv .venv
source .venv/bin/activate        # Windows: .venv\Scripts\activate

pip install -e ".[dev]"

pytest tests/ -v
pytest tests/ -v --cov=aws_cost_cli

Project structure

aws_cost_cli/
├── cli.py            Click commands and routing
├── cost_explorer.py  AWS Cost Explorer API calls
├── formatter.py      Rich terminal output and CSV export
├── periods.py        Time period resolution (7d, mtd, last-month…)
├── budget.py         Local budget storage (~/.aws-cost-cli/)
└── notify.py         Slack webhook notifications

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aws_cost_cli-0.1.0.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aws_cost_cli-0.1.0-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file aws_cost_cli-0.1.0.tar.gz.

File metadata

  • Download URL: aws_cost_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aws_cost_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3c9ef82886de058038e98b16f00a3acf30915512a3958a606c5699c40293bcd7
MD5 c6be63cb472de0552d0bc44c432f126f
BLAKE2b-256 a76e19b548f7eec5e6f9de2b7657c8a74816dbb46f54b84256ff4d68113268c4

See more details on using hashes here.

File details

Details for the file aws_cost_cli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: aws_cost_cli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aws_cost_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 762bcbb9534c91dbb85d28383acef5839cf1f2aec85ff60077809eaa834033de
MD5 e44e0df45563ec250bc28cf62ff2a1df
BLAKE2b-256 8b9b6698e63c74bc989353db230f7e11a307a511c3f641d0fae4dd49fb472aed

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page