Infracost shows cloud cost estimates for infrastructure-as-code projects such as Terraform. It helps developers, devops and others to quickly see a cost breakdown and compare different options upfront.
If you're upgrading from an older version to
v0.8, please see the migration guide.
Assuming Terraform is already installed, get the latest Infracost release:
- macOS Homebrew
- macOS manual
Subsequent updates can be installed in the usual way:
brew upgrade infracost (you might need
brew update first if your brew isn't up-to-date)
Download and unzip the latest release. Rename the file
infracost.exe, then run it from the Command Prompt or Powershell using
.\infracost.exe --no-color alongside other required commands/flags (color output has a bug we need to fix on Windows). You should also move the exe file to a folder that is in your
PATH environment variable, e.g.
Register for a free API key:
The key is saved in
Run Infracost using our example Terraform project to see how it works:
Use our CI/CD integrations to automatically add pull request comments showing cost estimate diffs.
As mentioned in the FAQ, no cloud credentials, secrets, tags or resource identifiers are sent to the Cloud Pricing API. That API does not become aware of your cloud spend; it simply returns cloud prices to the CLI so calculations can be done on your machine. Infracost does not make any changes to your Terraform state or cloud resources.
infracost CLI has the following main commands. Use the
--path flag to point to a Terraform directory or plan JSON file:
breakdown: show full breakdown of costs
diff: show diff of monthly costs between current and planned state
If your repo has multiple Terraform projects or workspaces, use an Infracost config file to define them; their results will be combined into the same breakdown or diff output.
As shown below, any required Terraform flags can be passed using
--terraform-workspace flag can be used to define a workspace.
Internally Infracost runs Terraform init, plan and show; init requires cloud credentials to be set, e.g. via the usual
GOOGLE_CREDENTIALS environment variables.
Point to a Terraform plan JSON file using
--path. This implies that Terraform
init has been run, thus Infracost just runs Terraform
show, which does not require cloud creds to be set.
See the advanced usage guide for other usage options.
infracost breakdown --help to see the available options, which include:
infracost diff --help and
infracost output --help commands show related options.