CI/CD troubleshooting
This page describes steps you can follow to troubleshoot CI/CD integrations. Contact us if you're having problems with source control integrations.
1. Enable additional logging
If the Infracost CLI fails, re-run it with --log-level=debug
or the INFRACOST_LOG_LEVEL=debug
environment variable in case that provides helpful details.
If the Terraform CLI fails, check their debugging page for help. Likewise, if the Terragrunt CLI fails, check their debugging page for help.
2. Generating plan JSON files
By default, the Infracost CLI parses Terraform HCL code to estimate costs. If that does not work for your use-case, Infracost can also parse the Terraform/Terragrunt plan JSON file.
If you have multiple Terraform plan JSON files, you can
- run
infracost breakdown
with--path plan-1.json --format json --out-file infracost-1.json
to generate an Infracost JSON file for each. - run
infracost output
with--path "infracost-*.json" --format diff
(glob patterns need quotes) to combine the Infracost JSON files into one output format then use that file withinfracost comment
. Theinfracost output --help
command shows the other options.
3. Check supported versions
Check the Terraform version matches what you expect. Infracost works with Terraform v0.12 and above.
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. Posting comments
If you're having issues posting pull request comments, please review the troubleshooting section for your version control system:
- GitHub
- GitLab
- Azure Repos
- Bitbucket > see the Troubleshooting section
5. Infracost Cloud dashboard
If your pull request comments are being posted but they are not showing in the dashboard, ensure that the:
- In Infracost Cloud's Org settings page, the cost estimate dashboard is enabled.
- Infracost CLI version (
infracost --version
) being used is latest patch version of v0.10. - Required environment variables are set before the
infracost breakdown
andinfracost diff
commands are run. You can verify this by runningcat infracost.json | jq .metadata
orinfracost breakdown --path /code --format json | jq .metadata
and checking the Infracost JSON block shows your pull request metadata. - Either
infracost comment
orinfracost upload
is used in your CI/CD integration. If Infracost Cloud is enabled (step 1 above), these commands send the Infracost JSON data to your organization in Infracost Cloud.