AWS Cost Calculator CLI - Calculate daily and annual AWS costs across multiple accounts
Project description
AWS Cost Calculator (cc)
A CLI tool to quickly calculate AWS costs across multiple accounts.
Installation
cd ~/cost-calculator
pip install -e .
Quick Start
1. Login to AWS SSO
aws sso login --profile khoros_umbrella
Note: You need to do this before running cost calculations. The SSO session typically lasts 8-12 hours.
2. Initialize a profile
cc init --profile khoros \
--aws-profile khoros_umbrella \
--accounts "642760139656,145679567042,180770971501,971806087770,683318854735,280985057266,093946224578,947367733247,052386936954,519148787890,361242680605,820054669588,215874735434,557798917917,947339144938,219578106441,584263334748,187869093632,779692108586,342253892223,441519177493,501640268289,597327850421,460151422989,396913733701,312094195081,080387571914,937384382519,566466540491,342218928671,918503513377,315476810393,202209793760,764203154397,610274503051,113301878575,641691899753,347754356580,752095361202,910599465992,808850080010,810305106688,169126548117,908518190937,352833962087,129542220929,946624006600,740994884060"
3. Calculate costs
# Default: Today minus 2 days, going back 30 days
cc calculate --profile khoros
# Specific start date
cc calculate --profile khoros --start-date 2025-11-04
# Custom offset and window
cc calculate --profile khoros --offset 2 --window 30
# JSON output
cc calculate --profile khoros --json-output
4. List profiles
cc list-profiles
How It Works
Date Calculation
- Start Date: Defaults to today, or specify with
--start-date - Offset: Days to go back from start date (default: 2)
- Window: Number of days to analyze (default: 30)
Example: If today is Nov 4, 2025:
- With offset=2, window=30: Analyzes Oct 3 - Nov 2 (30 days)
Cost Calculation
- Operational Costs: Sum of daily costs ÷ window days
- Support Allocation:
- Gets support cost from the analysis month
- Divides by 2 (half allocated to Khoros)
- Divides by days in that month
- Daily Rate: Operational + Support per day
- Annual Projection: Daily rate × 365
Filters Applied
- Billing Entity: AWS only (excludes marketplace)
- Excluded: Tax, Support (calculated separately)
- Metric: Net Amortized Cost
Configuration
Profiles are stored in: ~/.config/cost-calculator/profiles.json
Example:
{
"khoros": {
"aws_profile": "khoros_umbrella",
"accounts": ["642760139656", "145679567042", ...]
}
}
Examples
# Quick daily check
cc calculate --profile khoros
# Historical analysis
cc calculate --profile khoros --start-date 2025-10-01
# Export to JSON for processing
cc calculate --profile khoros --json-output > costs.json
# Different window size
cc calculate --profile khoros --window 60
Output
Analyzing: 2025-10-03 to 2025-11-02 (30 days)
AWS Profile: khoros_umbrella
Accounts: 48
Fetching cost data...
Fetching support costs...
============================================================
Period: 2025-10-03 to 2025-11-02
Days analyzed: 30
============================================================
Total operational cost: $1,339,508.57
Daily operational: $43,209.95
Support (month): $41,484.71
Support per day (÷2÷days): $669.11
============================================================
DAILY RATE: $43,879.06
ANNUAL PROJECTION: $16,015,858
============================================================