Infracost
$ infracost Official Low Riskinfracost parses Terraform/OpenTofu HCL or plan JSON locally and queries the Infracost Cloud Pricing API to produce monthly cloud cost breakdowns and PR diffs. It provides both --format json and --llm compact output, making it purpose-built for FinOps checks by coding agents.
brew install infracost Local HCL parser with native --format json and --llm flags; dramatically faster and more accurate than asking an LLM to guess AWS/GCP/Azure pricing.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Provides --format json, --json log mode, --llm compact output, and --no-color, though requires an API key (INFRACOST_API_KEY) for pricing lookups.
- Supports
--format json,--json, and--llmoutput flags - Non-interactive execution when
INFRACOST_API_KEYis set
Read-only static analysis of Terraform/OpenTofu code; only sends anonymized resource pricing queries (no secrets or cloud account IDs) to the pricing API.
- Zero cloud provider credentials required; read-only local parsing
Single Go binary available via Homebrew, Docker, Chocolatey, and GitHub Releases on macOS, Linux, and Windows.
- Static Go binary across all major platforms
Replaces error-prone manual pricing calculator lookups with deterministic per-resource cost diffs.
- Supports AWS, Azure, and GCP resource pricing from HCL or plan JSON
Official infracost/infracost project under Apache-2.0 with active maintenance.
- Official vendor CLI under Apache-2.0
Well-organized docs covering CLI flags, usage files (infracost-usage.yml), and CI integrations.
- Detailed CLI reference at infracost.io/docs/
Security, Auth & Guardrails
Stores the Cloud Pricing API key in ~/.config/infracost/credentials.yml or reads INFRACOST_API_KEY from the environment.
CLI is Apache-2.0 open-source; Cloud Pricing API has a generous free tier for individuals and small teams, with paid org plans for CI guardrails.
# Infracost Agent Rules - Ensure `INFRACOST_API_KEY` is configured before running `breakdown` or `diff`. - Pass `--format json` or `--no-color` when parsing outputs programmatically. - Treat `infracost breakdown` as read-only cost estimation; never expose API keys in logs.
Agent-Ready Command Recipes
Safe Read-Only Queries
infracost breakdown --path . --format json
Estimates monthly cloud spend from local HCL files and returns structured per-resource cost JSON.
infracost diff --path . --compare-to infracost-base.json --format json
Computes exact monthly cost delta between current code and a saved baseline.
Strengths for Agents
- + Native
--format jsonand--llmflags tailor output for automated pipelines and agents. - + Parses HCL directly without requiring
terraform initor cloud credentials. - +
infracost diffquantifies exact monthly cost deltas before merge.
Caveats & Pitfalls
- ! Requires
INFRACOST_API_KEY(viainfracost auth loginor env var) to query live pricing data. - ! Usage-based resources (egress, Lambda invocations) rely on
infracost-usage.ymlestimates.