Infracost
Infracost is an open-source tool that estimates the monthly cloud cost of Terraform changes before you apply them. It shows a per-resource breakdown and the cost difference between current and proposed infrastructure.
What Is Infracost?
Infracost reads Terraform code or plan JSON and prices each resource from cloud pricing data. It is most useful as a pull request check that posts the cost change next to the code diff.
terraform plan -out=tfplan.binaryterraform show -json tfplan.binary > plan.jsoninfracost breakdown --path plan.jsoninfracost diff --path . --compare-to infracost-base.jsonTipInfracost cannot know runtime usage like data transfer or Lambda invocations unless you supply a usage file. Treat the number as the cost of the infrastructure shape.
Frequently Asked Questions
How does Infracost price infrastructure without deploying it?
It reads your code or plan to see which resources and attributes will exist, then looks up matching unit prices and multiplies by hours or assumed usage.
Why does a usage-based resource show a low cost?
Usage-based charges are unknown from a static plan, so they default to zero unless you provide a usage file.