As of Infracost CLI v0.9.7, Terragrunt projects are automatically detected when passed in via the
Standard Terragrunt CLI options such as
TERRAGRUNT_PARALLELISM can be passed as environment variables such as:
If your Terragrunt project has multiple modules and you want to specify different usage files for each module, you will need to add each Terragrunt subdirectory and usage file to the Infracost config file.
If you have any feedback about how we should support multiple usage files with Terragrunt in the future, please comment on or follow this issue.
By default, that Dockerfile uses Terraform 0.15.5, but you can set the environment variable
TERRAGRUNT_TFPATH to any of the supported versions so Terragrunt uses that version, e.g.
- Infracost detects a Terragrunt project by checking for a Terragrunt config file in the specified path, which will be
terragrunt.hcl.jsonor the value of the
TERRAGRUNT_CONFIGenvironment variable. If Infracost does not detect your project as a Terragrunt project, make sure this file exists in the specified path or in any of the subdirectories with a depth less than 5.
- If Terragrunt is detected Infracost runs
terragrunt run-all plan -out <tmpfile>against the directory to generate plan files for all projects. We use the
--terragrunt-ignore-external-dependenciesflag to limit the cost estimate to only include infrastructure defined in the current directory.
- Infracost loops through all the Terragrunt modules and runs
terragrunt show <tmpfile>for each. This currently does not use the
terragrunt run-allfunctionality since it's not possible to match the output from that to a specific module.
- Infracost outputs a diff or breakdown for each Terragrunt module.
Pre v0.9.7 Infracost did not have native support for Terragrunt. Old configurations will still work, but can now be simplified.
- You no longer need to set
terragruntunless you are using a non-standard binary path.
- You no longer need to specify multiple Terragrunt modules in your Infracost config file, unless you want to specify per-project usage. Infracost will now detect all the Terragrunt modules that exist under the specified
- The Terragrunt breakdown_all.sh and diff_all.sh will be deprecated and will no longer be maintained. The functionality provided by these is now supported within the Infracost binary.