Infracost works with Terraform v0.12 and above.
To change the path to the
terraform binary, set the
INFRACOST_TERRAFORM_BINARY env variable:
Infracost itself does not need any cloud credentials.
Infracost runs Terraform internally and depending on which Infracost usage method is used, Terraform will need access to cloud credentials, e.g. when running
terraform init and
terraform plan. These commands are only used to produce plan JSON files and no changes are made to your Terraform state or cloud resources.
Infracost gets prices from the Cloud Pricing API. We offer a free Cloud Pricing API and continually update it with the latest cloud vendor prices.
No cloud credentials, secrets, tags or Terraform resource identifiers are sent to the open-source Cloud Pricing API. Infracost does not make any changes to your Terraform state or cloud resources.
The Cloud Pricing API does not become aware of your cloud spend; it returns price points to the CLI so calculations can be done on your machine. The Cloud Pricing API needs the relevant data to return a unique cloud price point. We also send the count of Terraform resource types to the Cloud Pricing API to enable us to better prioritize support for new resources. Additional context such as the operating system, Terraform version, type of CI system, and Infracost version are also sent alongside error tracking events so we can identify and fix issues quickly.
Here is an example request to the Cloud Pricing API for a t3.micro instance and the returned response:
Yes! The Cloud Pricing API repo has instructions on how it can be run. You can point the Infracost CLI to your deployment using the
INFRACOST_PRICING_API_ENDPOINT environment variable, e.g. https://cloud-pricing-api.mydomain.com.
The key differences are:
- Infracost is free and open-source, Terraform Cloud's cost estimation is paid and closed source.
- Infracost supports more resources than Terraform Cloud's cost estimation feature.
- Infracost has a CLI tool that can be used in your terminal or integrated into your workflows regardless of what source control and CI/CD system you use.
- Infracost can be used with Terragrunt.
- Infracost can output HTML reports or JSON and used alongside other tools.