Infracost shows cloud cost estimates for Terraform. It enables DevOps, SRE and engineers to see a cost breakdown and understand costs before making changes, either in the terminal or pull requests. This provides your team with a safety net as people can discuss costs as part of the workflow.
Assuming Terraform is already installed, get the latest Infracost release:
macOS Homebrew:
brew install infracost
Linux/macOS manual download:
# Downloads the CLI based on your OS/arch and puts it in /usr/local/bin
curl -fsSL https://raw.githubusercontent.com/infracost/infracost/master/scripts/install.sh | sh
Docker and Windows users see here.
Register for a free API key, which is used by the CLI to retrieve prices from our Cloud Pricing API, e.g. get prices for instance types. No cloud credentials or secrets are sent to the API and you can also self-host it.
infracost register
The key can be retrieved with infracost configure get api_key
.
Infracost does not make any changes to your Terraform state or cloud resources. Run Infracost using our example Terraform project to see how it works. The CLI commands page describes the options for --path
, which can point to a Terraform directory or plan JSON file.
git clone https://github.com/infracost/example-terraform.git
cd example-terraform/sample1
# Play with main.tf and re-run to compare costs
infracost breakdown --path .
# Show diff of monthly costs, edit the yml file and re-run to compare costs
infracost diff --path . --sync-usage-file --usage-file infracost-usage.yml
Use our CI/CD integrations to add cost estimates to pull requests, it only takes 15 minutes. This provides your team with a safety net as people can understand cloud costs upfront, and discuss them as part of your workflow.
If you run into any issues, please join our community Slack channel, we'll help you very quickly 😄
The infracost
CLI has the following main commands, see our docs for the other commands:
Infracost supports over 230 Terraform resources across AWS, Azure and Google. Other IaC tools, such as Pulumi, AWS CloudFormation/CDK and Azure ARM/Bicep are on our roadmap.
See this page for details on cost estimation of usage-based resources such as AWS Lambda or Google Cloud Storage.
Issues and pull requests are welcome! For development details, see the contributing guide. For major changes, including CLI interface changes, please open an issue first to discuss what you would like to change. Join our community Slack channel, we are a friendly bunch and happy to help you get started :)
Thanks to all the people who have contributed, including bug reports, code, feedback and suggestions!