Infracost shows cloud cost estimates for Terraform projects. It helps developers, devops and others to quickly see the cost breakdown and compare different options upfront.
-
Assuming Terraform is already installed, get the latest Infracost release:
macOS Homebrew:
brew install infracost
Linux/macOS manual:
os=$(uname | tr '[:upper:]' '[:lower:]') && \ curl -s -L https://github.com/infracost/infracost/releases/latest/download/infracost-$os-amd64.tar.gz | tar xz -C /tmp && \ sudo mv /tmp/infracost-$os-amd64 /usr/local/bin/infracost
Docker and Windows users see here.
-
Use our free Cloud Pricing API by registering for an API key:
infracost register
The key is saved in
~/.config/infracost/config.yml
. If you prefer, you can run your own Cloud Pricing API. -
Run
infracost
using our example Terraform project to see how it works.git clone https://github.com/infracost/example-terraform.git cd example-terraform # You can play with `aws/main.tf` and `aws/infracost-usage.yml`, and re-run infracost to compare costs infracost --tfdir aws --usage-file aws/infracost-usage.yml
Please watch/star this repo as we add new cloud resources every week or so.
There are 4 usage methods for Infracost depending on your use-case. The following is the default method. Point to the Terraform directory using --tfdir
and pass any required Terraform flags using --tfflags
. Internally Infracost runs Terraform init
, plan
and show
; init
requires cloud credentials to be set, e.g. via the usual AWS_ACCESS_KEY_ID
environment variables. This method works with remote state too.
infracost --tfdir /path/to/code --tfflags "-var-file=myvars.tfvars"
Checkout the docs site for additional usage options, including notes for Terragrunt and Terraform Cloud users.
As mentioned in the FAQ, you can run Infracost in your Terraform directories without worrying about security or privacy issues as 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 following CI/CD integrations can be used to automatically add a comment showing the cost estimate diff
between a pull request and the master branch:
If you run into any issues with CI/CD integrations, please join our community Slack channel, we'd be happy to guide you through it.
Infracost supports over 50 AWS and Google resources, Azure is planned. The quickest way to find out if your Terraform resources are supported is to run Infracost with the --show-skipped
option. This shows the unsupported resources, some of which might be free. Please watch this repo for new releases as we add new cloud resources every week or so.
See this page for details on cost estimation of usage-based resources.
Issues and pull requests are welcome! For development details, see the contributing file. For major 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 :)