ConfigsApr 16, 2026·3 min read

Infracost — Cloud Cost Estimates for Infrastructure as Code

See cloud cost breakdowns before you deploy. Infracost integrates with Terraform and CI/CD to show how every change impacts your bill.

Introduction

Infracost shows cloud cost estimates for Terraform projects right in pull requests and the terminal. Engineers see the dollar impact of infrastructure changes before they merge, shifting cost awareness left into the development workflow.

What Infracost Does

  • Parses Terraform HCL and plan JSON to estimate monthly costs
  • Posts cost diffs as comments on GitHub, GitLab, and Bitbucket pull requests
  • Supports AWS, Azure, and Google Cloud pricing with 1M+ price points
  • Provides a breakdown of cost per resource, module, and project
  • Offers usage-based estimates for services like S3, Lambda, and data transfer

Architecture Overview

Infracost is a Go CLI that reads Terraform plan output or HCL files directly. It resolves resource types to the Cloud Pricing API, an open-source GraphQL service backed by a PostgreSQL database of public cloud pricing. The CLI generates a JSON cost report that can be piped into the comment formatter for CI integration.

Self-Hosting & Configuration

  • Install via brew, curl script, Docker, or prebuilt binaries for Linux, macOS, and Windows
  • Run infracost auth login to get a free API key for the hosted pricing API
  • Optionally self-host the Cloud Pricing API with a local PostgreSQL instance
  • Add infracost diff to CI pipelines via GitHub Actions, GitLab CI, or Jenkins
  • Configure an infracost.yml usage file to model expected consumption for usage-based resources

Key Features

  • Shift-left cost visibility with pull request cost comments
  • Supports over 1 million cloud price points across three major providers
  • HCL parsing mode works without running terraform plan
  • FinOps policies via cost thresholds and Conftest/OPA integration
  • Open-source core with a free tier for individual and small-team use

Comparison with Similar Tools

  • AWS Cost Explorer — Retrospective analysis of existing spend; Infracost predicts cost before deployment
  • Terraform Cloud Cost Estimation — Built into TFC but limited to HashiCorp plans; Infracost is open-source and CI-agnostic
  • OpenCost — Monitors live Kubernetes spend; Infracost estimates IaC changes pre-deploy
  • Pulumi Cost Estimation — Pulumi-only; Infracost focuses on the Terraform ecosystem

FAQ

Q: Is Infracost free? A: The open-source CLI and Cloud Pricing API are free. A paid tier adds team dashboards, guardrails, and priority support.

Q: Does it require running terraform plan? A: Not always. The HCL parsing mode estimates costs directly from code without a plan, though plan-based mode is more accurate for dynamic values.

Q: Which cloud providers are supported? A: AWS, Azure, and Google Cloud. Community contributions cover additional resources over time.

Q: Can I set cost budgets in CI? A: Yes. Infracost supports threshold-based policies that fail a CI check if estimated costs exceed a limit.

Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets