diff --git a/configstack/module.go b/configstack/module.go index ba845d5a64..ceb1e4bece 100644 --- a/configstack/module.go +++ b/configstack/module.go @@ -441,14 +441,18 @@ func (modules TerraformModules) flagIncludedDirs(opts *options.TerragruntOptions // flagUnitsThatAreIncluded iterates over a module slice and flags all modules that include at least one file in // the specified include list on the TerragruntOptions ModulesThatInclude attribute. func (modules TerraformModules) flagUnitsThatAreIncluded(opts *options.TerragruntOptions) (TerraformModules, error) { - // If no ModulesThatInclude is specified return the modules list instantly - if len(opts.ModulesThatInclude) == 0 { + // The two flags ModulesThatInclude and UnitsReading should both be considered when determining which + // units to include in the run queue. + unitsThatInclude := append(opts.ModulesThatInclude, opts.UnitsReading...) + + // If no unitsThatInclude is specified return the modules list instantly + if len(unitsThatInclude) == 0 { return modules, nil } modulesThatIncludeCanonicalPaths := []string{} - for _, includePath := range opts.ModulesThatInclude { + for _, includePath := range unitsThatInclude { canonicalPath, err := util.CanonicalPath(includePath, opts.WorkingDir) if err != nil { return nil, err diff --git a/docs/_docs/04_reference/cli-options.md b/docs/_docs/04_reference/cli-options.md index 70be716377..05996a9b40 100644 --- a/docs/_docs/04_reference/cli-options.md +++ b/docs/_docs/04_reference/cli-options.md @@ -1297,9 +1297,12 @@ and then will apply this filter on the set of modules that it found. You can pass this argument in multiple times to provide a list of include files to consider. When multiple files are passed in, the set will be the union of modules that includes at least one of the files in the list. -NOTE: When using relative paths, the paths are relative to the working directory. This is either the current working +**NOTE**: When using relative paths, the paths are relative to the working directory. This is either the current working directory, or any path passed in to [terragrunt-working-dir](#terragrunt-working-dir). +**TIP**: This flag is functionally covered by the `--terragrunt-queue-include-units-reading` flag, but is more explicitly +only for the `include` configuration block. + ### terragrunt-queue-include-units-reading **CLI Arg**: `--terragrunt-queue-include-units-reading`
@@ -1313,11 +1316,11 @@ directory, or any path passed in to [terragrunt-working-dir](#terragrunt-working - [destroy-all (DEPRECATED: use run-all)](#destroy-all-deprecated-use-run-all) - [validate-all (DEPRECATED: use run-all)](#validate-all-deprecated-use-run-all) -This flag works very similarly to the `--terragrunt-modules-that-include` flag, but instead of looking for included configurations, -it instead looks for configurations that read a given file. +This flag works very similarly to the `--terragrunt-modules-that-include` flag, but instead of looking only for included configurations, +it also looks for configurations that read a given file. When passed in, the `*-all` commands will include all units (modules) that read a given file into the queue. This is useful -when you want to trigger an update on all units that read a given file using HCL functions in their configurations. +when you want to trigger an update on all units that read or include a given file using HCL functions in their configurations. Consider the following folder structure: diff --git a/test/fixtures/units-reading/including/terragrunt.hcl b/test/fixtures/units-reading/including/terragrunt.hcl new file mode 100644 index 0000000000..839b3f755e --- /dev/null +++ b/test/fixtures/units-reading/including/terragrunt.hcl @@ -0,0 +1,3 @@ +include "shared" { + path = find_in_parent_folders("shared.hcl") +}