Skip to main content

Get started

Infracost helps teams shift left on cloud costs by catching and fixing issues directly in the engineering workflow—before they become expensive problems. It provides cost estimates for Terraform before deployment, checks for FinOps best practices. These are aligned with cloud vendor Well-Architected Frameworks and your company's tagging standards. Infracost even opens AutoFix pull requests to resolve issues automatically. This means engineers can prevent new cost surprises, fix existing problems with a single merge, and keep cost discussions inside the workflow they already use. Infracost supports AWS, Azure, and Google Cloud.

1. Install Infracost

Get the latest Infracost release:

brew install infracost

infracost --version # Should show 0.10.42

To upgrade Infracost, run brew update then brew upgrade infracost.


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.

note
  • No cloud credentials or secrets are sent to the API.
  • Infracost does not make any changes to your Terraform state or cloud resources.
infracost auth login

The key can be retrieved with infracost configure get api_key.


3. Show cost estimate breakdown

Infracost parses the project locally to determine resource types and quantities needed to calculate costs. The --path flag should point to your Terraform directory.

# You can also: git clone https://github.com/infracost/example-terraform
cd my-terraform-project
# Terraform variables can be set using --terraform-var-file or --terraform-var
infracost breakdown --path .

Example output:

Infracost breakdown command
tip

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


4. Add to your CI/CD

Use our integrations to add Infracost to pull requests, it only takes 15 minutes! This provides your team with a safety net as people can understand cloud costs and FinOps best practices upfront, and discuss them as part of your workflow. See our demo video to learn more.

If you run into any issues, please join our community Slack channel, we'll help you very quickly 😄

Infracost pull request comment