Open fitzoh opened 4 years ago
Thanks for providing the repro!
The bug here is that xxx-all
is trying to parse the terragrunt.hcl
you have at the root folder in isolation when it is building up the stack (see Configuration parsing order for more details), and it can't do that because file
fails. Note that skip = true
has no effect because the error is during the parsing step: it can't even skip the file because it hasn't parsed skip
!
I think the fix for this is to update the parsing logic to do 2 passes: the first pass is just partially parsing the skip
attribute to ignore the root terragrunt.hcl
, and then exclude those with skip=true
before going through the second pass to parse the configs.
With that said, here are two workarounds:
You can rename the root terragrunt.hcl
(e.g., root.hcl
) and update the child config to use path = find_in_parent_folder("root.hcl")
for the include
block. This ensures that xxx-all
calls at the root won't attempt to parse the root terragrunt.hcl.
You can wrap the yamldecode
call in a try. This ensures that terragrunt can parse the config while building up the stack, and then skip it when it sees skip = true
.
Versions
Terragrunt v0.23.29 Terraform v0.12.28
Short Description
The
path_relative_*_include
functions appear to behave differently when used in a base terraform command in a child directory (terragrunt plan
) than when used in a*-all
command in the parent directory (terragrunt plan-all
).Reproducing
I have included a minimal example here: https://github.com/fitzoh/terragrunt-relative-paths
Use case
I'm creating multiple instances of the same module and am planning on storing the version of the module to use in a yaml file in the directory for each instance.
The parent terragrunt file will then set the source modules based on a tag stored in the yaml file.
This currently works fine if I run it directly from the repo, but blows up when I try to run it using the
*-all
functions as it can't find the config files.