Skip to content

Cloud cost estimates for Terraform in pull requests💰📉 Love your cloud bill!

License

Notifications You must be signed in to change notification settings

matthieupetite/infracost

 
 

Repository files navigation

Infracost logo

Docs Community Slack channel Build Status CodeQL status Docker Image Tweet

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.

Infracost in GitHub Actions

Quick start

1. Install Infracost

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.

2. Get API key

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.

3. Run it

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 between current and planned state
infracost diff --path .

Infracost can also estimate usage-based resources such as AWS S3 or Lambda.

4. Add to CI/CD

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 😄

CLI commands

The infracost CLI has the following main commands, see our docs for the other commands:

Show full breakdown of costs

Infracost breakdown command

Show diff of monthly costs between current and planned state

Infracost diff command

Supported clouds and resources

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.

Contributing

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!

License

Apache License 2.0

About

Cloud cost estimates for Terraform in pull requests💰📉 Love your cloud bill!

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 97.4%
  • Shell 2.3%
  • Other 0.3%