terragrunt-infrastructure-live-example icon indicating copy to clipboard operation
terragrunt-infrastructure-live-example copied to clipboard

How to access global variables from application/service layer

Open archenroot opened this issue 3 years ago • 3 comments

In main terragrunt.hcl file are merged following:

# Configure root level variables that all resources can inherit. This is especially helpful with multi-account configs
# where terraform_remote_state data sources are placed directly into the modules.
inputs = merge(
  local.account_vars.locals,
  local.region_vars.locals,
  local.environment_vars.locals,
)

But in the example they are never accessed, how to access them from subdirs?

archenroot avatar Nov 02 '21 09:11 archenroot

I have found another way to do it via imports, but that is traversing the other way trough a tree: https://github.com/gruntwork-io/terragrunt-infrastructure-live-example/issues/70

archenroot avatar Nov 02 '21 13:11 archenroot

No, it works via inputs, while in this directory the region and account hcl files defines locals instead of inputs, so it won't work..hm..

archenroot avatar Nov 02 '21 13:11 archenroot

Checkout https://terragrunt.gruntwork.io/docs/features/keep-your-terragrunt-architecture-dry/, in particular the section on exposed includes. I believe that is what you are looking for.

yorinasub17 avatar Nov 02 '21 16:11 yorinasub17