Infracost shows cloud cost estimates for infrastructure-as-code projects such as Terraform. It helps DevOps, SRE and developers to quickly see a cost breakdown and compare different options upfront.
If you're upgrading from an older version to
v0.9, please see the migration guide.
Assuming Terraform is already installed, get the latest Infracost release:
- macOS Homebrew
- macOS manual
If the version is old, please run
brew update then
brew upgrade infracost.
Download and unzip the latest release. 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.
infracost CLI has the following main commands. Use the
--path flag to point to either 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 mentioned in our FAQ, no cloud credentials or secrets are sent to the Cloud Pricing API. Infracost does not make any changes to your Terraform state or cloud resources.
This is the simplest way to run Infracost. As shown below, any required Terraform flags can be passed using
--terraform-workspace flag can be used to define a workspace.
If the above method does not work for your use-case, you can use Terraform to generate a plan JSON file (as shown below), and point Infracost to it using
--path. In this case, cloud credentials are not needed by Infracost.
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. For shell completion scripts, see
infracost completion --help.