DevOps Tools
Open-Source FinOps: A Deep Dive into OpenInfraQuote for Terraform Cost Estimation
Looking for a free, open-source way to estimate Terraform costs? This article takes a deep dive into OpenInfraQuote. Learn how this lightweight tool lets you check costs locally and in your CI/CD pipeline without sending your data to any external services. It's perfect for teams who value privacy, control, and no vendor lock-in.
Open-Source FinOps: A Deep Dive into OpenInfraQuote for Terraform Cost Estimation

In the rapidly evolving world of FinOps, the ability to forecast cloud costs before deployment is paramount. While commercial tools have led the charge, a growing demand for open-source, self-contained solutions has emerged. Answering this call is OpenInfraQuote, a lightweight, MPL-2.0 licensed command-line interface (CLI) tool designed to estimate infrastructure costs directly from Terraform files. Built by Terrateam, it offers teams a way to gain cost visibility without vendor lock-in, API keys, or external dependencies.

The Philosophy Behind OpenInfraQuote

The creators of OpenInfraQuote built it with a clear set of goals centered on developer freedom, privacy, and control.

  • 100% Open Source and Control: With an MPL-2.0 license, the tool is free from restrictive commercial licensing. Users have full control over the code and its usage.

  • Simple and Lightweight: OpenInfraQuote is a self-contained CLI binary. It runs locally or in any CI/CD environment without requiring a backend, external services, or API keys. This means your data never leaves your system.

  • Extendable by Design: The tool is built to be easily integrated into existing pipelines and expanded upon based on community needs.

This approach is ideal for teams that prioritize data privacy, operate in air-gapped environments, or simply prefer the transparency and control that open-source software provides.

How OpenInfraQuote Works

OpenInfraQuote calculates infrastructure cost changes by analyzing the JSON output from Terraform plan and state files. This reliance on structured JSON output ensures stability and consistency in its estimates. The process involves two main commands piped together: oiq match and oiq price.

  1. oiq match: This command takes a pricing sheet and a Terraform plan/state JSON file as input. It matches the resources defined in the JSON file with the corresponding price points from the pricing sheet.

  2. oiq price: This command takes the output of oiq match and calculates the final cost estimate, applying region-specific pricing and usage data.

Getting Started: A Step-by-Step Guide

Step 1: Installation

First, you need to install the oiq binary and download the cloud provider pricing sheet.

  1. Install the oiq CLI: Go to the OpenInfraQuote GitHub releases page and download the appropriate binary for your system. Unarchive the file and move the oiq executable to a directory in your $PATH.

    Shell

    # Example for macOS
    curl -LO https://github.com/terrateamio/openinfraquote/releases/download/v1.10.0/oiq-darwin-amd64-v1.10.0.tar.gz
    tar -xzf oiq-darwin-amd64-v1.10.0.tar.gz
    sudo mv oiq /usr/local/bin/
    sudo chmod +x /usr/local/bin/oiq
    

    Verify the installation by running oiq --help.

  2. Download the Pricing Sheet: Before running an estimate, you must download the latest pricing data.

    Shell

    curl -s https://oiq.terrateam.io/prices.csv.gz | gunzip > prices.csv
    

    This prices.csv file should be available to the oiq command during execution.

Step 2: Generate a Terraform Plan JSON

OpenInfraQuote operates on the JSON representation of a Terraform plan.

  1. Navigate to your Terraform project directory and initialize it.

    Shell

    terraform init
    
  2. Create a binary plan file.

    Shell

    terraform plan -out=tf.plan
    
  3. Convert the binary plan to a JSON file.

    Shell

    terraform show -json tf.plan > tfplan.json
    

    You now have the tfplan.json file that OpenInfraQuote will analyze.

Step 3: Run the Cost Estimation

With the setup complete, you can now generate a cost estimate.

Shell

oiq match --pricesheet prices.csv tfplan.json | oiq price --region us-east-1

The --region flag is recommended for region-specific estimates. You can also get the output in JSON format by adding --format=json to the price command, which is ideal for CI/CD automation.

Handling Usage-Based Resources

For resources priced based on usage (e.g., storage size), OpenInfraQuote includes default estimates. However, you can provide your own usage.json file to customize these assumptions and achieve more accurate estimates.

Integrating into CI/CD

OpenInfraQuote is designed for easy integration into any CI/CD pipeline, such as GitHub Actions, GitLab, or Atlantis. The process typically involves adding steps to your pipeline to install oiq, download the pricing sheet, generate the plan JSON, and execute the cost estimation command. The output can be used to post a comment on a pull request or fail the pipeline if a cost threshold is exceeded.

Conclusion

OpenInfraQuote offers a compelling vision for the future of open-source FinOps. By providing a simple, secure, and self-contained CLI tool, it empowers teams to gain critical cost visibility without compromising on privacy or control. Its transparent, community-driven approach and ease of integration make it an excellent choice for any organization looking to build a cost-aware culture on its own terms.

See, Understand, Optimize -
All in One Place

Atler Pilot decodes your cloud spend story by bringing monitoring, automation, and intelligent insights together for faster and better cloud operations.