Terragrunt
The Infracost breakdown
and diff
commands automatically detect Terragrunt projects, though we generally recommend setting up a config file for Terragrunt repos.
infracost breakdown --path=path/to/terragrunt/repo
The --exclude-path
flag can be used to exclude any directories/modules that should not be run, for example:
infracost breakdown --path=. --exclude-path=dev --exclude-path=test
Usage file
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, see an example here.
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.
Source map
The INFRACOST_TERRAFORM_SOURCE_MAP
environment variable is useful when you want to replace module URLs used by Infracost (e.g. replace private URLs with public ones). See this docs section for more details.
How the Terragrunt integration works
With v0.10, when the CLI's --path
flag points to a Terragrunt directory:
Infracost detects a Terragrunt project by checking for a Terragrunt config file in the specified path, which will be
terragrunt.hcl
,terragrunt.hcl.json
or the value of theTERRAGRUNT_CONFIG
environment 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 downloads any required source files to an
.infracost
cache, detects Terragrunt defined inputs, then parses HCL directly.Infracost outputs a diff or breakdown for each Terragrunt module.