Reputation: 95
For this terragrunt directory structure:
project
environment-dev
_common
region
apps
app-a
subenv.hcl
app-b
subenv.hcl
app-c
subenv.hcl
... # other apps can be added in the future
app-x
subenv.hcl
account.hcl
and in each subenv.hcl
file there is (among other config) this snipet:
# tags
app_tags = {
"App_tag" = "app-x"
}
I would like to have in the account.hcl
a local variable called app_name
which values is input manually but to add a validation for this value, https://developer.hashicorp.com/terraform/language/expressions/custom-conditions#input-variable-validation. This validation to only allow a value for app_name
in the account.hcl
from the values of App_tag
of each subenv.hcl
file down the directory tree.
I was thinking to use read_terragrunt_config
with 'find_in_parent_folders', https://terragrunt.gruntwork.io/docs/reference/built-in-functions/#read_terragrunt_config but 'find_in_parent_folders' searches up the directory tree and not down; the account.hcl
file should get variable values from files which are down the tree and also from all of the files found down the directory tree.
Thank you.
Upvotes: 1
Views: 169
Reputation: 81
You can only use statically defined include
configuration block, meaning for every app-n
you'll have to add include to your account.hcl
.
It would be easier to store app_name
constraints higher in the hierarchy and refer it in account.hcl
and in subenv.hcl
s
Upvotes: 0