opentofuterraformcost-estimationci-cd

OpenTofu cost estimation: price your infrastructure from tofu plan

OpenTofu emits the same plan JSON as Terraform, so cost estimation works unchanged — run tofu show -json and price it. Here's how to estimate OpenTofu cost locally and in CI, and what stays identical after the fork.

The C3X Team··5 min read

Quick answer

OpenTofu emits the same plan JSON as Terraform, so cost estimation works unchanged: run tofu plan -out=tofu.plan, then tofu show -json tofu.plan, and price the result. The .tf syntax and provider resources are shared, so the estimate is identical to Terraform's, no cloud credentials, same CI workflow.

Teams moving to OpenTofu ask the obvious question: does the tooling still work? For cost estimation the answer is yes, and the reason is simple, OpenTofu is a fork that kept the plan format. Anything that prices a Terraform plan prices an OpenTofu plan the same way.

Same plan format, same estimate

The accurate way to estimate is from the plan, because it resolves variables, for_each, conditionals, and data sources, see plan JSON as the most accurate input. OpenTofu produces that same JSON:

tofu init -input=false
tofu plan -out=tofu.plan -input=false
tofu show -json tofu.plan > plan.json
c3x estimate --path plan.json

Swap terraform for tofu and everything downstream is unchanged.

Raw HCL works too

The configuration language is shared, so a static estimate over the .tf files works for a quick local read without generating a plan. As with Terraform, prefer the plan in CI for accuracy; use HCL for a fast local sanity check.

c3x estimate --path ./infra

What OpenTofu features do and don't change

OpenTofu's own features, state encryption, early variable evaluation, provider-defined functions, affect how the plan is produced, not which billable resources it contains. The instances, databases, and gateways are still provider resources, priced from their configuration. The estimate reads that resolved output, so the number matches what the same infrastructure would cost under Terraform.

In CI

Wire it exactly like the Terraform flow: plan, convert to JSON, estimate, comment, gate on a budget. The pattern is identical whether you run GitHub Actions, GitLab CI, or Atlantis, only the tofu binary differs. Add a budget gate to fail the build on a breach.

FAQ

Does cost estimation work with OpenTofu?

Yes, without changes. OpenTofu is a fork of Terraform and emits the same plan JSON format (tofu show -json). A cost estimator that reads Terraform plan JSON reads OpenTofu plan JSON identically, because the schema is the same.

How do I estimate cost from a tofu plan?

Run tofu plan -out=tofu.plan, then tofu show -json tofu.plan > plan.json, then estimate that plan.json. It's the same three steps as Terraform with tofu in place of terraform.

Can I estimate raw OpenTofu HCL without a plan?

Yes. The .tf configuration syntax is shared between OpenTofu and Terraform, so a static HCL estimate works for a quick local check. As with Terraform, estimating the plan is more accurate because it resolves variables, for_each, and data sources.

Do OpenTofu-specific features change the estimate?

The resources that cost money, instances, databases, storage, load balancers, are provider resources priced from your configuration, and providers behave the same under OpenTofu. OpenTofu features like state encryption or early variable evaluation change how the plan is produced, not what the priced resources are.

Does it need OpenTofu installed in CI to estimate?

Only to produce the plan. If your pipeline already runs tofu plan, the estimation step just consumes the JSON output, it doesn't need to run OpenTofu again, and it needs no cloud credentials.

Will estimates stay compatible as OpenTofu evolves?

As long as the plan JSON format version stays stable, yes. A well-built estimator keys off the documented plan schema, not on Terraform-specific internals, so it tracks both tools. If a future format version changes, the estimator updates its parser, the workflow stays the same.

What to do next

Point the estimator at your OpenTofu plan and get a number in seconds. C3X reads OpenTofu and Terraform plans alike, prices the resources against a live catalog, and runs locally, in CI, or as a PR comment, free and self-hostable. Start with the quickstart.

Try C3X on your own Terraform

Free and open source. No API key required. One command to install, one command to estimate.