aws-cost-report

Production-grade AWS Cost Explorer CLI, Month-over-Month Delta Engine, and Automated SRE Budget Guardrail.

aws-cost-report generate --compare
========================================================================================================
                                   AWS MONTHLY BILLING & USAGE REPORT
========================================================================================================
 Account ID:         715195480427
 Billing Month:      September 2026
 Period:             2026-09-01 to 2026-09-30 (inclusive)
 Currency:           USD
 Estimated / Final:  Finalized
 Active Services:    14
--------------------------------------------------------------------------------------------------------
 Metric                   |       Amount (USD) |        Prev (USD) |         Diff ($) |              % Δ
--------------------------------------------------------------------------------------------------------
 Unblended Cost           |              21.58 |             21.13 |            +0.45 |           +2.13%
 Blended Cost             |              21.59 |             21.14 |            +0.45 |           +2.13%
 Amortized Cost           |              21.58 |             21.13 |            +0.45 |           +2.13%
========================================================================================================

--------------------------------------------------------------------------------------------------------
 Service Name                               | Unblended (USD) |     Prev (USD) |   Diff ($) |        % Δ
--------------------------------------------------------------------------------------------------------
 Amazon DynamoDB                            |            5.51 |           5.20 |      +0.31 |     +5.96%
 AWS Config                                 |            4.73 |           4.80 |      -0.07 |     -1.46%
 Amazon Cognito                             |            4.17 |           4.15 |      +0.02 |     +0.48%
 Tax                                        |            2.89 |           2.80 |      +0.09 |     +3.21%
 AWS Key Management Service                 |            1.00 |           1.00 |       0.00 |      0.00%
 Amazon Simple Storage Service              |            0.94 |           0.88 |      +0.06 |     +6.82%
 Amazon Route 53                            |            0.80 |           0.80 |       0.00 |      0.00%
 Amazon CloudWatch                          |            0.65 |           0.70 |      -0.05 |     -7.14%
 AWS Secrets Manager                        |            0.40 |           0.40 |       0.00 |      0.00%
 AWS Lambda                                 |            0.25 |           0.18 |      +0.07 |    +38.89%
========================================================================================================

Why aws-cost-report?

⚡ Instant Local Visibility

No need to log in to the slow AWS Billing Console. View categorized monthly infrastructure costs and Month-over-Month deltas directly in your terminal in milliseconds.

🛡️ SRE Budget Guardrail

Block CI/CD deployment pipelines before expensive infrastructure accidents happen using --fail-on-threshold=FLOAT to exit with code 1.

📈 Multi-Format Engines

Output exact fixed-width terminal tables, GitHub Actions Step Summaries (Markdown), structured JSON for pipelines, or CSV for financial reporting.

🏷️ Tag & Account Grouping

Group billing metrics by AWS SERVICE, LINKED_ACCOUNT, or custom cost allocation tags like TAG:Environment or TAG:Project.

🌍 Multi-Currency Support

Automatically detects billing currencies (EUR, GBP, JPY, CAD, AUD, USD) from AWS responses and formats symbols and delta headers accordingly.

Installation

1. Homebrew (macOS & Linux)

brew tap smford/homebrew-tap
brew install aws-cost-report

2. Static Binary Downloads

Direct standalone binaries built for high performance and zero external dependencies:

3. GitHub Action

Drop aws-cost-report directly into your GitHub Actions workflow:

- name: Run AWS Cost Report
  uses: smford/aws-cost-report@latest
  with:
    compare: 'true'
    threshold: '500.00'
    format: 'markdown'

4. Docker Container

docker pull ghcr.io/smford/aws-cost-report:latest

Usage Examples

Instant CLI Help (Zero Latency)

aws-cost-report

Standard Monthly Report

aws-cost-report generate

Month-over-Month Delta Comparison

aws-cost-report generate --compare

Human-Readable Account Labeling

Display a friendly name for the AWS account alongside the 12-digit AWS Account ID in report headers. Automatically discovers your IAM Account Alias via iam:ListAccountAliases, or can be explicitly overridden:

# Explicitly set account alias via CLI:
aws-cost-report generate --compare --name="Production Core"

List Official AWS Cost Explorer Services

aws-cost-report services

Filtering by Service Name or Alias

aws-cost-report generate --filter="Amazon DynamoDB,AWS Lambda"
# Using common aliases:
aws-cost-report generate --filter="S3,EC2,KMS"

Filtering by Cost Allocation Tags

Scope your entire report to tagged workloads with native AWS Cost Explorer server-side filtering:

# Filter by single tag
aws-cost-report generate --tag="Environment=Production"

# Multi-value filter (logical OR) with MoM delta comparison
aws-cost-report generate --tag="Environment=Production,Staging" --compare

# Compound tag filtering (logical AND)
aws-cost-report generate --tag="Environment=Production" --tag="Project=FinOps"

# Combine tag filtering with Linked Account breakdown
aws-cost-report generate --tag="Environment=Production" --group-by="LINKED_ACCOUNT"

Multi-Dimensional Grouping

Group costs by up to two dimensions simultaneously to drill down into costs across accounts, services, and tag dimensions:

# Service breakdown by Environment tag:
aws-cost-report generate --group-by="SERVICE,TAG:Environment"

# Linked Account breakdown by Service:
aws-cost-report generate --group-by="LINKED_ACCOUNT,SERVICE"

# Multi-tag matrix (e.g. Environment + Team):
aws-cost-report generate --group-by="TAG:Environment,TAG:Team"

Identifying Untagged Costs

When you group costs by an AWS Cost Allocation Tag dimension, AWS Cost Explorer aggregates all resources missing that tag into an empty tag key value. The tool automatically maps this to Untagged / Other.

1. View Breakdown of All Tag Values (Including Untagged Spend)

aws-cost-report generate --group-by="TAG:Environment"

In the generated report table, an Untagged / Other line item reflects all costs incurred by resources lacking the Environment tag.

2. Isolate Untagged Costs Only

Use the --filter option to match the untagged line item and dynamically recalculate report totals:

aws-cost-report generate --group-by="TAG:Environment" --filter="Untagged"

3. Track Untagged Cost Trends Month-over-Month

Add --compare to evaluate whether untagged spend is increasing or decreasing compared to previous periods:

aws-cost-report generate --group-by="TAG:Environment" --filter="Untagged" --compare

📌 Key Considerations

  • Tag Activation: The tag key (e.g., Environment, Owner, Project) must be activated as a Cost Allocation Tag in the AWS Billing and Cost Management console before Cost Explorer can track or group by it.
  • Evaluated Per Tag Key: AWS Cost Explorer does not provide a global "completely untagged" dimension across all potential tags simultaneously; grouping evaluates untagged resources for the specific tag key requested (e.g., TAG:Environment, TAG:CostCenter).
  • Cost Aggregation vs. Resource IDs: The tool reports aggregate monetary figures (e.g., $450.00 on Untagged / Other), but does not enumerate individual resource ARNs or IDs (which would require AWS Config or the AWS Resource Groups Tagging API).

Multi-Month Historical Trend (Column Format)

View up to 12+ historical billing months in a multi-column pivot table where each month is rendered in its own dedicated column alongside cumulative totals:

# View previous 12 months side-by-side in column format:
aws-cost-report generate --months=12 --monthly

# View previous 6 months:
aws-cost-report generate --months=6 --monthly

# Export 12-month pivot table to CSV for spreadsheet analysis:
aws-cost-report generate --months=12 --monthly --format=csv -o 12-months.csv

Month-to-Date (MTD) Spend Tracking

Query real-time in-progress spend for the active month up to today, with automatic comparison against the same day window last month:

# Query Month-to-Date spend for current billing cycle:
aws-cost-report generate --mtd

# Compare current MTD spend against the same day window last month:
aws-cost-report generate --mtd --compare

Daily Spend Granularity

Analyze day-by-day spending patterns across your billing window with daily totals, day-of-week context, daily averages, and the top cost driver for each day:

# Query daily spend breakdown for current month:
aws-cost-report generate --daily

# Combine daily granularity with Month-to-Date (MTD) tracking:
aws-cost-report generate --daily --mtd

# Export daily breakdown to CSV:
aws-cost-report generate --daily --format=csv -o daily-spend.csv

Prometheus Metrics Exporter

Scrape real-time AWS cost metrics in standard Prometheus exposition format (version 0.0.4) for Grafana dashboards:

# Start HTTP microservice daemon:
aws-cost-report --server

# Scrape metrics:
curl http://localhost:8080/metrics

# Or export directly via CLI:
aws-cost-report generate --format=prometheus

Compact & Minimal Format (--format=minimal)

A high-density, compact output engine designed for automated notifications, chat webhooks, CI/CD step logs, and mobile screens. It eliminates wasteful whitespace (keeping row width ≤ 45 characters), surfaces MoM cost increases, excludes non-service lines like tax, and rolls up long tails into a clean top-5 table:

# Generate minimal report with comparison and account name:
aws-cost-report generate --compare --format=minimal --account-name="Production Core"
*AWS Billing Report — October 2026*
*Account:* `715195480427` (Production Core)
*Period:* 2026-10-01 to 2026-10-31 (Finalized)
*Total Spend:* *$21.58 USD* (prev: $21.13)
*MoM Change:* *+2.13%* (+$0.45)

*Cost Increases:*
• *Amazon DynamoDB*: $5.51 (+$0.31 / +5.96%)
• *AWS Lambda*: $0.25 (+$0.07 / +38.89%)
• *Amazon Simple Storage S...*: $0.94 (+$0.06 / +6.82%)

```
Services (Top 5)      Spend      Diff       %
---------------------------------------------
Amazon DynamoDB       $5.51    +$0.31   +6.0%
AWS Config            $4.73    -$0.07   -1.5%
Amazon Cognito        $4.17    +$0.02   +0.5%
AWS Key Managem...    $1.00     $0.00    0.0%
Amazon Simple S...    $0.94    +$0.06   +6.8%
Other (8 svcs)        $2.34    +$0.04   +1.7%
---------------------------------------------
Total                $21.58    +$0.45   +2.1%
```

Budget Guardrail & Predictive Forecast

Terminate with exit code 1 if current spend breaches your budget, or use machine learning predictions to alert if projected month-end spend is on track to breach your limit:

# Guardrail on actual spend:
aws-cost-report generate --threshold=50.00

# Predictive guardrail on projected month-end spend:
aws-cost-report generate --forecast --threshold=50.00

GitHub Actions Job Summary

aws-cost-report generate --format=markdown --compare

Shell Autocompletion

# Zsh:
source <(aws-cost-report completion zsh)

# Bash:
source <(aws-cost-report completion bash)

# Fish:
aws-cost-report completion fish | source

Exporting Reports to Amazon S3

Save formatted reports and JSON metric summaries directly to an S3 bucket via s3:// URIs or bucket flags:

# Export markdown report directly to S3:
aws-cost-report generate --compare --output="s3://my-billing-bucket/reports/2026-10.md"

# Export report and JSON summary simultaneously to S3:
aws-cost-report generate --compare \
  --output="s3://my-billing-bucket/cost-report.md" \
  --json-summary="s3://my-billing-bucket/cost-summary.json"

Enterprise Discount Program (EDP) & Net Cost Metrics

For accounts with AWS Enterprise Discount Program (EDP) or private pricing agreements, query net metrics:

# Query EDP net metrics alongside standard unblended costs:
aws-cost-report generate --compare --metrics="UnblendedCost,NetUnblendedCost,NetAmortizedCost"

# Or query all supported metrics at once:
aws-cost-report generate --compare --metrics=all

SRE Workflow with Threshold Outputs

- name: Run AWS Cost Report
  id: cost
  uses: smford/aws-cost-report@latest
  with:
    compare: 'true'
    threshold: '1000.00'
    fail-on-threshold: 'false'

- name: Notify on Breach
  if: steps.cost.outputs.threshold-breached == 'true'
  run: echo "Warning: Cost breached threshold ($${{ steps.cost.outputs.total-cost }})"