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.
-
Assuming Terraform is already installed, get the latest Infracost release:
macOS Homebrew:
brew install infracost
Linux/macOS manual download:
os=$(uname | tr '[:upper:]' '[:lower:]') && \ arch=$(uname -m | tr '[:upper:]' '[:lower:]' | sed -e s/x86_64/amd64/) && \ curl -s -L https://github.com/infracost/infracost/releases/latest/download/infracost-$os-$arch.tar.gz | tar xz -C /tmp && \ sudo mv /tmp/infracost-$os-$arch /usr/local/bin/infracost
Docker and Windows users see here.
-
Register for a free API key:
infracost register
The key is saved in
~/.config/infracost/credentials.yml
. -
Run Infracost using our example Terraform project to see how it works:
git clone https://github.com/infracost/example-terraform.git cd example-terraform # Play with sample1/main.tf and re-run to compare costs infracost breakdown --path sample1 # Show diff of monthly costs, edit the yaml file and re-run to compare costs infracost diff --path sample1 --usage-file sample1/infracost-usage.yml
Please watch/star this repo as we add new cloud resources every week or so.
The infracost
CLI has the following main commands, their usage is described in our short getting started page:
breakdown
: show full breakdown of costsdiff
: show diff of monthly costs between current and planned state
As mentioned in our 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.
The following CI/CD integrations can be used to automatically add a pull request comment showing the diff of monthly costs between the current and planned state:
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 80 AWS and Google resources; Microsoft Azure is coming soon. Other IaC tools (Pulumi, CloudFormation) are on our roadmap too.
We regularly add support for new resources so we recommend watching this repo for releases: click on the Watch button > selecting Custom > Releases and click on Apply.
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, 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 :)