Skip to main content

CI/CD integrations

Infracost 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. Minor cost increase/decrease changes can be ignored by setting a threshold for the comment to be added.

Infracost can be used in any CI/CD system using the infracost binary or the infracost/infracost Docker image. You might also find our CI diff script useful; it's used in the following integrations.

GitHub Action

See our new Infracost actions repo for instructions and examples. If you used the older infracost-gh-actions repo, please see our migration guide.

Example Infracost diff output

GitLab CI

See the Infracost GitLab CI template for instructions, and a demo here.

Example Infracost diff output

CircleCI

See the Infracost CircleCI Orb for instructions; it supports GitHub and Bitbucket. A demo of the GitHub integration is here, and Bitbucket is here

Bitbucket Pipelines

See the Infracost Bitbucket Pipeline for instructions, and a demo here.

Example Infracost diff output

Atlantis

See the Infracost Atlantis integration for instructions. There is a demo here, expand the Show Output sections and scroll down to see the Infracost output.

Example Infracost diff output

Jenkins

See the Infracost Jenkins integration for instructions, and a demo here.

Example Infracost diff output

Azure DevOps

See the Infracost Azure DevOps integration for instructions. A demo of the Azure DevOps Repos (git) integration is here, and GitHub repos is here.

Example Infracost diff output

Terraform Cloud Run Tasks

See the Run Tasks integration for instructions and the following screenshot for a demo. Run Tasks is a beta Terraform Cloud feature that can be used to integrate Infracost into the Terraform Cloud pipeline directly. This enables Infracost to work with Terraform Cloud natively, meaning you do not need to install/upgrade our CLI into your CI/CD systems.

Infracost running as a Run Task

Slack

All of the above CI/CD integrations support also posting the pull request comment to a Slack channel. To enable it, create a Slack Webhook and set its value to the SLACK_WEBHOOK_URL environment variable.

Example Infracost diff output

CI/CD troubleshooting

Please try the following steps and if that doesn't help, create an issue or join our community Slack channel to chat with us.

  1. Set the INFRACOST_LOG_LEVEL environment variable to debug in case that provides more useful details. For Atlantis, also set atlantis_debug=true.
  2. Check the Terraform version that Infracost is using matches the version you need. Use the INFRACOST_TERRAFORM_BINARY environment variable to change that.
  3. Use ls -lah in the CI build to check for any .terraform* files/folders that might be confusing Terraform running in CI vs previous runs that were used to create them. Removing those files might help.
  4. Check the Terraform Cloud/Enterprise or Terragrunt docs pages if applicable.

My CI/CD isn't supported

Please create an issue; we'll try to prioritize it depending on the community feedback. There is already a request for BuildKite. Please 👍 it if you'd like us to work on them sooner. You can also join our community Slack channel if you like to work on an integration, the existing integrations can act as a blueprint.