Skip to content

JacobDavidAlcock/CloudCost

Repository files navigation

CloudCost ☁️💰

Release Go Version License

Fast multi-cloud cost visibility in your terminal.

CloudCost is a CLI that shows your AWS, Azure, and GCP spending in seconds. No dashboards, no web browsers just fast cost data in your terminal.

CloudCost Demo

Features

  • Multi-Cloud Support - AWS, Azure, and GCP in one command
  • Lightning Fast - 1-hour local cache makes repeat queries instant (10x faster)
  • 🎨 Beautiful Terminal UI - Progress bars, colors, and clear formatting
  • 🔒 Secure - Uses your existing cloud CLI credentials
  • 📊 Tag Grouping - Group costs by team, environment, or any tag
  • 📅 Date Ranges - Current month, last month, or any YYYY-MM
  • 💾 JSON Output - Pipe to jq or other tools

Quick Start

Installation

Download pre-built binary (recommended):

# Linux (AMD64)
curl -L https://github.com/JacobDavidAlcock/CloudCost/releases/latest/download/cloudcost-linux-amd64 -o cloudcost
chmod +x cloudcost
sudo mv cloudcost /usr/local/bin/

# macOS (Apple Silicon)
curl -L https://github.com/JacobDavidAlcock/CloudCost/releases/latest/download/cloudcost-darwin-arm64 -o cloudcost
chmod +x cloudcost
sudo mv cloudcost /usr/local/bin/

# macOS (Intel)
curl -L https://github.com/JacobDavidAlcock/CloudCost/releases/latest/download/cloudcost-darwin-amd64 -o cloudcost
chmod +x cloudcost
sudo mv cloudcost /usr/local/bin/

# Windows (PowerShell)
Invoke-WebRequest -Uri "https://github.com/JacobDavidAlcock/CloudCost/releases/latest/download/cloudcost-windows-amd64.exe" -OutFile "cloudcost.exe"

Or build from source:

git clone https://github.com/JacobDavidAlcock/cloudcost.git
cd cloudcost
go build ./cmd/cloudcost

Basic Usage

# AWS costs (default)
cloudcost report --cloud aws

# Multi-cloud aggregated view
cloudcost report --cloud all

# Group by tags
cloudcost report --cloud aws --group-by team

# Last month's costs
cloudcost report --cloud azure --month last-month

# JSON output
cloudcost report --cloud gcp --output json

Setup Guide

AWS Setup

CloudCost uses your existing AWS credentials (~/.aws/credentials or environment variables).

# Check authentication
cloudcost auth aws

# List available profiles
cloudcost auth aws --list-profiles

# Use specific profile
cloudcost report --cloud aws --profile production

Requirements:

  • AWS CLI configured with valid credentials
  • Cost Explorer API access (enabled by default)

Azure Setup

CloudCost uses Azure CLI credentials.

# 1. Login to Azure CLI
az login

# 2. Set your subscription ID
export AZURE_SUBSCRIPTION_ID="your-subscription-id"

# 3. Verify authentication
cloudcost auth azure

# 4. Fetch costs
cloudcost report --cloud azure

Requirements:

  • Azure CLI installed and authenticated
  • Cost Management Reader role or higher
  • AZURE_SUBSCRIPTION_ID environment variable set

GCP Setup

CloudCost requires BigQuery billing export (one-time setup).

# 1. Authenticate with gcloud
gcloud auth application-default login

# 2. Set project ID
export GOOGLE_CLOUD_PROJECT="your-project-id"

# 3. Enable BigQuery billing export
gcloud billing export create \
  --dataset-id=billing_export \
  --location=US

# 4. Wait 24 hours for data to populate

# 5. Verify authentication
cloudcost auth gcp

# 6. Fetch costs
cloudcost report --cloud gcp

Requirements:

  • gcloud CLI installed and authenticated
  • BigQuery billing export enabled
  • GOOGLE_CLOUD_PROJECT environment variable set
  • 24 hours after export setup for data to populate

Command Reference

Authentication

# Check AWS auth
cloudcost auth aws

# Check Azure auth
cloudcost auth azure

# Check GCP auth
cloudcost auth gcp

# List AWS profiles
cloudcost auth aws --list-profiles

Cost Reports

# Single cloud
cloudcost report --cloud aws
cloudcost report --cloud azure
cloudcost report --cloud gcp

# Multi-cloud aggregated
cloudcost report --cloud all

# Date ranges
cloudcost report --cloud aws --month current
cloudcost report --cloud aws --month last-month
cloudcost report --cloud aws --month 2024-10

# Tag grouping
cloudcost report --cloud aws --group-by team
cloudcost report --cloud aws --group-by environment
cloudcost report --cloud gcp --group-by project

# Output formats
cloudcost report --cloud aws --output table  # default
cloudcost report --cloud aws --output json

# AWS profiles
cloudcost report --cloud aws --profile production

# Bypass cache
cloudcost report --cloud aws --no-cache

Other Commands

# Show version
cloudcost --version

# Show help
cloudcost --help
cloudcost report --help
cloudcost auth --help

Caching

CloudCost caches API responses for 1 hour in ~/.cloudcost/cache/ to:

  • Reduce API costs
  • Speed up repeat queries (10x faster: 2s → 0.2s)
  • Enable offline viewing of recent data
# Use cache (default)
cloudcost report --cloud aws

# Bypass cache for fresh data
cloudcost report --cloud aws --no-cache

Cache is automatically invalidated after 1 hour.

Examples

View AWS costs grouped by team

cloudcost report --cloud aws --group-by team

Output:

 AWS Costs (November 2025)

  Total: $12,450.00

By Team:

Team: Platform         $6,200.00
Team: Data             $4,100.00
Team: Mobile           $2,150.00

Compare all clouds

cloudcost report --cloud all --month last-month

Output:

 Multi-Cloud Costs (October 2025)

  Total: $45,230.00

By Cloud Provider:

  AWS                                   $32,100.00 ███████████████████░  71.0%
  Azure                                 $10,050.00 █████░░░░░░░░░░░░░░░  22.2%
  GCP                                    $3,080.00 █░░░░░░░░░░░░░░░░░░░   6.8%

Warnings:
  Azure: (not configured)
  GCP: (not configured)

Export to JSON and process with jq

# Get total AWS costs
cloudcost report --cloud aws --output json | jq '.Total'

# List services over $100
cloudcost report --cloud aws --output json | \
  jq '.Services | to_entries | map(select(.value > 100)) | from_entries'

Troubleshooting

AWS: "Authentication failed"

  • Run aws configure to set up credentials
  • Check ~/.aws/credentials file exists
  • Verify IAM permissions include Cost Explorer access

Azure: "No subscription ID found"

# Get your subscription ID
az account list --query "[].{Name:name, ID:id}" -o table

# Set environment variable
export AZURE_SUBSCRIPTION_ID="<your-id>"

GCP: "Billing export dataset not found"

# Enable billing export
gcloud billing export create --dataset-id=billing_export --location=US

# Check status
gcloud billing export list

# Note: Takes 24 hours for data to populate after setup

Cache issues

# Clear cache manually
rm -rf ~/.cloudcost/cache

# Or bypass cache
cloudcost report --cloud aws --no-cache

Project Structure

cloudcost/
├── cmd/
│   └── cloudcost/
│       └── main.go                      # CLI entrypoint
├── internal/
│   ├── auth/
│   │   ├── aws.go                       # AWS authentication
│   │   ├── azure.go                     # Azure authentication
│   │   └── gcp.go                       # GCP authentication
│   ├── cache/
│   │   └── cache.go                     # File-based caching (1hr TTL)
│   ├── providers/
│   │   ├── aws/
│   │   │   └── costs.go                 # AWS Cost Explorer API
│   │   ├── azure/
│   │   │   └── costs.go                 # Azure Cost Management API
│   │   ├── gcp/
│   │   │   └── costs.go                 # GCP BigQuery billing export
│   │   └── multicloud/
│   │       └── aggregate.go             # Multi-cloud aggregation
│   └── display/
│       └── table.go                     # Terminal UI rendering
├── go.mod
├── go.sum
└── README.md

Roadmap

v0.2.0 (Next)

  • Config file support (~/.cloudcost/config.yaml)
  • Homebrew/Chocolatey packages
  • Test coverage

v0.3.0

  • Historical cost trends
  • Cost comparison (this month vs last)
  • Budget alerts

Future Ideas

  • Team dashboards
  • Slack/email notifications
  • Cost optimization recommendations
  • Persistent storage (90+ days)

Architecture

CloudCost uses official cloud provider APIs:

  • AWS: Cost Explorer API
  • Azure: Cost Management API
  • GCP: BigQuery billing export

All credentials use your existing cloud CLI authentication. No data is sent to external servers—everything runs locally on your machine.

FAQ

Q: How do I "log out"? A: CloudCost doesn't store credentials. It uses your existing cloud CLI credentials. To "log out," use your cloud provider's CLI (e.g., aws configure, az logout, gcloud auth revoke).

Q: Why does GCP require BigQuery? A: GCP doesn't have a Cost Explorer-like REST API. BigQuery billing export is the official way to programmatically access GCP billing data.

Q: How much does it cost to use CloudCost? A: CloudCost is free to use under the Elastic License 2.0. You only pay for your cloud provider's API costs (typically $0.01-0.10/month).

Q: Why is my data 24 hours old? A: AWS Cost Explorer and Azure Cost Management update once per day. This is a limitation of the cloud providers, not CloudCost.

Q: Can I use this in CI/CD? A: Yes! Use --output json to pipe data to other tools. CloudCost works great in automation pipelines.

Contributing

Pull requests are welcome. Open an issue first for major changes.

License

Elastic License 2.0 - Free to use, modify, and distribute. You cannot provide CloudCost as a hosted/managed service to third parties. See LICENSE for full details.

Support

About

Fast multi-cloud cost visibility in your terminal. View AWS, Azure, and GCP spending in seconds.

Resources

License

Stars

Watchers

Forks

Languages