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 breakdownwith--path plan-1.json --format json --out-file infracost-1.jsonto generate an Infracost JSON file for each. - run
infracost outputwith--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 --helpcommand 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 breakdownandinfracost diffcommands are run. You can verify this by runningcat infracost.json | jq .metadataorinfracost breakdown --path /code --format json | jq .metadataand checking the Infracost JSON block shows your pull request metadata. - Either
infracost commentorinfracost uploadis 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.