Skip to content

CLI tool to perform cost analysis on your infrastructure account with Slack integration.

License

Notifications You must be signed in to change notification settings

codecollab-co/infra-cost

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

128 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’° infra-cost

Multi-cloud FinOps CLI tool for comprehensive cost analysis and infrastructure optimization

npm version Downloads License: MIT GitHub issues GitHub stars

Take control of your cloud costs across AWS, Google Cloud, Azure, Alibaba Cloud, and Oracle Cloud πŸš€

Installation β€’ Quick Start β€’ Features β€’ Documentation β€’ Contributing


✨ What's New in v1.11.0

Advanced Cost Analysis & Security Fixes

  • πŸ“Š Cost Forecasting: Predict 1-12 months ahead with 4 statistical models (linear, exponential, seasonal, auto)
  • 🌐 Multi-Cloud Comparison: Compare costs across AWS, GCP, Azure, Oracle, Alibaba with service-level breakdowns
  • πŸ“ˆ Cost Trends: Analyze spending patterns with ASCII visualization and volatility detection
  • πŸ”’ Security Hardening: CORS restrictions, API key auth by default, memory leak fixes
  • ⚑ Performance: Async file operations, automatic cache cleanup, 85% faster responses

See CHANGELOG.md for complete release notes.


🎯 Why infra-cost?

Save money. Optimize resources. Make informed decisions.

  • πŸ’Έ Reduce cloud spend by up to 30% with actionable insights
  • πŸ” Multi-cloud visibility - see costs across all your providers in one place
  • ⚑ Real-time analysis - get instant cost breakdowns and trends
  • πŸ€– AI-powered recommendations for optimization opportunities
  • πŸ“Š Executive reports - beautiful PDF reports for stakeholders
  • πŸ”” Smart alerting - proactive cost anomaly detection
  • πŸ’¬ Team collaboration - Slack integration for cost awareness

πŸš€ Features

🌐 Multi-Cloud Support

  • AWS βœ… Full support with Cost Explorer integration
  • Google Cloud βœ… BigQuery billing export, multi-project support
  • Microsoft Azure 🚧 Architecture ready, coming soon
  • Alibaba Cloud 🚧 Architecture ready, coming soon
  • Oracle Cloud 🚧 Architecture ready, coming soon

πŸ“Š Comprehensive Analytics

  • Cost Forecasting - 1-12 month predictions with confidence intervals
  • Multi-Cloud Comparison - Side-by-side cost analysis across providers
  • Cost Trends - Historical analysis with visualization
  • Budget Monitoring - Track against budgets with smart alerts
  • Resource Rightsizing - ML recommendations for optimal instance sizes
  • Anomaly Detection - AI-powered cost spike identification

πŸŽ›οΈ Advanced Features

  • Interactive Dashboards - Rich terminal UI with real-time data
  • Terraform Cost Preview - Estimate costs before deployment
  • Git Cost History - Correlate cost changes with commits
  • IaC Annotations - Add cost comments to Terraform/CloudFormation files
  • AWS Organizations - Multi-account cost management
  • CI/CD Integration - GitHub Actions, Jenkins, GitLab CI

πŸ”§ Developer Experience

  • Multiple output formats: Fancy tables, plain text, JSON, CSV, Excel
  • Flexible authentication: Environment variables, IAM roles, profiles
  • Zero-config quick commands: infra-cost now for instant cost checks
  • API Server: REST endpoints for custom integrations
  • Webhook Support: Real-time notifications and integrations

πŸ“¦ Installation

npm (Recommended)

npm install -g infra-cost

Homebrew (macOS/Linux)

brew tap codecollab-co/tap
brew install infra-cost

npx (No installation required)

npx infra-cost

Docker

docker run --rm codecollab-co/infra-cost --help

GitHub Action

- uses: codecollab-co/infra-cost@v1.11.0
  with:
    provider: aws
    aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
    aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

🎯 Quick Start

1. Instant Cost Check

# Zero-config daily cost check
infra-cost now

# Output: Today's Cost: $45.23 (+$3.12 from yesterday)
#         Top Services: EC2 $22.10 | RDS $15.30 | S3 $4.20

2. AWS Cost Analysis

# Analyze costs with default AWS credentials
infra-cost cost analyze

# Show cost trends over time
infra-cost cost trends --period 30d

# Get cost forecast
infra-cost cost forecast --months 3

3. Google Cloud Platform

# Analyze GCP costs
infra-cost cost analyze \
  --provider gcp \
  --project-id my-project \
  --key-file /path/to/service-account.json

4. Multi-Cloud Comparison

# Compare costs across providers
infra-cost cost compare --providers aws,gcp,azure

5. Optimization & Monitoring

# Get optimization recommendations
infra-cost optimize recommendations

# Check cost alerts and budgets
infra-cost monitor alerts
infra-cost monitor budgets

πŸ” Authentication

AWS Authentication

Environment Variables (Recommended)

export AWS_ACCESS_KEY_ID=your_access_key
export AWS_SECRET_ACCESS_KEY=your_secret_key
export AWS_REGION=us-east-1
infra-cost cost analyze

AWS Profiles

infra-cost cost analyze --profile production

IAM Roles / AWS SSO

# Automatically uses attached IAM role
infra-cost cost analyze

# Or use AWS SSO
aws sso login --profile my-sso-profile
infra-cost cost analyze --profile my-sso-profile

Google Cloud Authentication

Service Account (Recommended)

export GOOGLE_PROJECT_ID=your-project-id
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account-key.json
infra-cost cost analyze --provider gcp

Application Default Credentials

gcloud auth application-default login
infra-cost cost analyze --provider gcp --project-id your-project-id

GCP Permissions Required:

  • resourcemanager.projects.get
  • bigquery.jobs.create
  • bigquery.tables.getData

Setup BigQuery Billing Export:

  1. Go to GCP Billing Console
  2. Enable "BigQuery export"
  3. Wait 24 hours for initial data

πŸ“– Command Reference

infra-cost uses a modern subcommand-based architecture. Here's a quick overview:

Quick Commands

  • infra-cost now - Instant daily cost check (zero config)
  • infra-cost free-tier - AWS Free Tier usage tracker
  • infra-cost annotate - Add cost comments to IaC files
  • infra-cost history - Git cost history and blame analysis

Core Command Groups

Cost Analysis - See detailed docs

  • cost analyze - Comprehensive cost analysis
  • cost forecast - Predict future costs (1-12 months)
  • cost compare - Multi-cloud cost comparison
  • cost trends - Historical cost trend analysis

Optimization - See detailed docs

  • optimize recommendations - AI-powered optimization suggestions
  • optimize quickwins - Find immediate savings opportunities
  • optimize rightsizing - Instance rightsizing recommendations
  • optimize cross-cloud - Cross-cloud optimization analysis

Monitoring & Alerts - See detailed docs

  • monitor alerts - Check cost alerts
  • monitor budgets - Monitor budget status
  • monitor watch - Real-time cost monitoring
  • monitor anomaly - Detect cost anomalies

Export & Reports - See detailed docs

  • export inventory json|csv|xlsx|pdf - Export resource inventory
  • chargeback report - Generate chargeback reports
  • chargeback slack - Send reports to Slack

AWS Organizations - See detailed docs

  • organizations list - List all accounts
  • organizations summary - Organization-wide cost summary
  • organizations daily - Daily costs for all accounts

Configuration

  • config init - Initialize configuration
  • config show - Show current configuration
  • config validate - Validate configuration
  • config migrate - Migrate from v0.x

Interactive Dashboards

  • dashboard interactive - Launch interactive TUI dashboard
  • dashboard multicloud - Multi-cloud dashboard

Terraform Integration - See detailed docs

  • terraform --plan <file> - Estimate costs before deployment

Get help for any command:

infra-cost --help
infra-cost cost --help
infra-cost cost analyze --help

πŸ—οΈ Architecture

infra-cost v1.0+ uses a clean architecture with:

  • Subcommand Architecture - Domain-organized, discoverable commands
  • Provider Pattern - Pluggable cloud provider implementations
  • Type Safety - Comprehensive TypeScript with Zod validation
  • Configuration First - Unified config system with profiles
  • Clean Separation - CLI, core logic, and providers are decoupled

See docs/code_flow.md for architecture details.

πŸ€– CI/CD Integration

GitHub Actions

name: Cost Analysis
on: [pull_request]

jobs:
  cost-check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: codecollab-co/infra-cost@v1.11.0
        with:
          provider: aws
          command: now
          comment-on-pr: true
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Terraform Cost Gates

- name: Terraform Cost Preview
  uses: codecollab-co/infra-cost@v1.11.0
  with:
    command: terraform
    additional-args: '--plan tfplan --threshold 20'

See docs/commands/CI_CD.md for more examples.

πŸ“Š Example Output

Cost Analysis

infra-cost cost analyze --output fancy

Cost Analysis

Interactive Dashboard

infra-cost dashboard interactive

Real-time cost monitoring with keyboard navigation, multiple views (Services, Resources, Trends, Alerts), and auto-refresh.

πŸ“š Documentation

User Documentation

Developer Documentation

See docs/README.md for complete documentation index.

πŸ› οΈ Development

# Clone and setup
git clone https://github.com/codecollab-co/infra-cost.git
cd infra-cost
npm install

# Build and test
npm run build
npm test

# Type checking and linting
npm run typecheck
npm run lint

# Run locally
npm run dev

See docs/DEVELOPMENT.md for detailed development guide.

🀝 Contributing

We welcome contributions! Here's how you can help:

  • ⭐ Star this repository to show your support
  • πŸ› Report bugs via GitHub Issues
  • πŸ’‘ Suggest features via GitHub Discussions
  • πŸ“ Improve documentation - help others understand the tool
  • πŸ”§ Add cloud provider support - help us expand to more providers
  • πŸ§ͺ Write tests - improve code quality

See CONTRIBUTING.md for detailed guidelines.

πŸ“ž Support & Community

Get Help

Enterprise Support

For enterprise deployments, custom integrations, and professional support:

  • πŸ“§ Contact: enterprise@codecollab.co
  • πŸ”’ SLA-backed support available
  • 🎨 Custom branding and whitelabeling
  • πŸ—οΈ Professional services and consulting

πŸš€ Roadmap

βœ… Completed (2024-2025)

  • βœ… AWS full support with Organizations
  • βœ… Google Cloud Platform support
  • βœ… Cost forecasting (4 statistical models)
  • βœ… Multi-cloud cost comparison
  • βœ… Interactive TUI dashboard
  • βœ… Terraform cost preview
  • βœ… GitHub Actions integration
  • βœ… Git cost history & blame
  • βœ… IaC file annotations

Q1-Q2 2026 (In Progress)

  • 🚧 Microsoft Azure integration
  • 🚧 Alibaba Cloud support
  • 🚧 Oracle Cloud support
  • πŸ“‹ VS Code extension
  • πŸ“‹ Enhanced forecasting models
  • πŸ“‹ Advanced automation engine

Future Vision

  • Carbon footprint tracking
  • Multi-tenant SaaS platform
  • Mobile app companion
  • Natural language queries
  • FinOps best practices automation

See full roadmap for detailed timeline.

πŸ“‹ Requirements

AWS Permissions

{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Action": [
      "iam:ListAccountAliases",
      "ce:GetCostAndUsage",
      "ce:GetRightsizingRecommendation",
      "budgets:ViewBudget",
      "sts:GetCallerIdentity"
    ],
    "Resource": "*"
  }]
}

System Requirements

  • Node.js 20+ (required)
  • Memory: 512MB+ available
  • Network: Internet access for cloud provider APIs

πŸ“„ License

MIT Β© Code Collab


Made with ❀️ by Code Collab

Empowering teams to optimize cloud costs and build sustainable infrastructure

⭐ Star us on GitHub β€’ 🐦 Follow on Twitter β€’ πŸ’Ό LinkedIn

About

CLI tool to perform cost analysis on your infrastructure account with Slack integration.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages