Skip to content

Go-based CLI that parses Terraform plans to estimate multi-cloud infrastructure costs (AWS/Azure/GCP) with CI/CD-friendly outputs.

License

Notifications You must be signed in to change notification settings

RaafehM/TerraQuote

Repository files navigation

terraquote

Terraform cost estimation tool for AWS, Azure, and GCP

terraquote is a CLI tool that parses Terraform plans and estimates cloud infrastructure costs across AWS, Azure, and GCP. The tool integrates with CI/CD pipelines to provide cost visibility before infrastructure deployment, preventing cost surprises.

What is terraquote?

terraquote helps you understand the cost implications of your Terraform infrastructure changes before you deploy them. By analyzing Terraform plans or HCL files, it provides accurate monthly cost estimates with confidence levels, helping teams make informed decisions about infrastructure changes.

Key Features

  • Multi-Cloud Support: Estimate costs for AWS, Azure, and GCP resources
  • Terraform Plan Parsing: Works with Terraform plan JSON files
  • Direct HCL Parsing: Analyze Terraform files directly without generating plans
  • Accurate Pricing: Uses official cloud provider pricing APIs with local caching
  • CI/CD Integration: Designed for GitHub Actions, GitLab CI, Azure DevOps, Bitbucket, and Jenkins
  • Usage-Based Modeling: Model variable costs (data transfer, requests, etc.) with usage profiles
  • Cost Thresholds: Enforce cost limits in CI/CD pipelines
  • Offline Operation: Works in air-gapped environments with bundled pricing data
  • Custom Pricing: Import enterprise discounts and custom pricing from billing exports

What Problems Does It Solve?

1. Prevent Cost Surprises

Get cost estimates before deploying infrastructure changes, avoiding unexpected bills at the end of the month.

2. CI/CD Cost Gates

Integrate cost checks into your CI/CD pipeline to automatically flag or block changes that exceed budget thresholds.

3. Cost Optimization

Identify expensive resources before deployment and explore cost-effective alternatives.

4. Budget Planning

Estimate costs for new infrastructure projects and plan budgets accordingly.

5. Multi-Cloud Cost Comparison

Compare costs across AWS, Azure, and GCP to make informed provider decisions.

Quick Start

Installation

# Build from source
git clone https://github.com/raafeh/terraquote.git
cd terraquote
go build -o bin/terraquote ./cmd/terraquote

Run with ./bin/terraquote from the project root, or add bin to your PATH and use terraquote directly.

Basic Usage

Estimate Costs from a Terraform Plan

# Generate a Terraform plan
terraform plan -out=plan.out
terraform show -json plan.out > plan.json

# Estimate costs
terraquote estimate plan.json

Estimate Costs Directly from HCL Files

# Analyze Terraform files directly (no plan needed)
terraquote check . --var-file=production.tfvars

Sync Pricing Data

# Sync pricing data from cloud provider APIs
terraquote pricing sync --providers aws,azure,gcp

# Check pricing cache status
terraquote pricing status

Usage-Based Cost Modeling

# Estimate with usage profile
terraquote estimate plan.json --usage-profile medium

# Compare multiple usage scenarios
terraquote estimate plan.json --compare-usage low,medium,high

For CI cost gates use --threshold-monthly or --threshold-percentage with --threshold-action fail|warn. For offline or air-gapped use, run terraquote estimate plan.json --offline (see Air-Gapped).

Output Formats

terraquote supports multiple output formats for different use cases:

  • Table (default): Human-readable console output
  • JSON: Machine-readable output for automation
  • Detailed: Comprehensive breakdown with confidence levels
  • GitHub: Formatted for GitHub PR comments
  • GitLab: Formatted for GitLab MR comments
  • Azure DevOps: Formatted for Azure DevOps PR comments
  • Bitbucket: Formatted for Bitbucket PR comments
  • Jenkins: Formatted for Jenkins console output
# JSON output
terraquote estimate plan.json --format json --output costs.json

# Detailed breakdown
terraquote estimate plan.json --format detailed

User Guides

For detailed usage instructions, see the comprehensive user guides:

Getting Started

Usage Scenarios

CI/CD Integration

Advanced Topics

Example Output

Resource                                    Provider  Monthly Cost    Confidence
─────────────────────────────────────────────────────────────────────────────────
aws_instance.web                            AWS      $15.36          exact
aws_s3_bucket.data                          AWS      $0.23           exact
  └─ Storage (1 GB)                         AWS      $0.02           exact
  └─ PUT requests (1,000)                   AWS      $0.01           exact
  └─ GET requests (10,000)                  AWS      $0.20           exact
azure_virtual_machine.app                   Azure    $73.00          exact
gcp_compute_instance.db                     GCP      $24.00          exact
─────────────────────────────────────────────────────────────────────────────────
Total Monthly Cost: $112.59

Documentation

For complete documentation, see the Documentation Hub:

Requirements

  • Go 1.21+ (if building from source)
  • Terraform (for generating plan files)
  • Cloud Provider Credentials (for syncing pricing data - see Credentials Guide)

License

See LICENSE file for details.

About

Go-based CLI that parses Terraform plans to estimate multi-cloud infrastructure costs (AWS/Azure/GCP) with CI/CD-friendly outputs.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages