Terragrunt: Is it possible to use terraform `locals.tf` within Terragrunt

Hello, I’ve a small question. Is it possible to use terraform variables/locals within terragrunt'? Basically I've a big block of tags defined inside oflocals.tffile, so I would like to use them with terragrunt.hcl`

Either:

  • place them in locals.hcl and load them in terragraunt with tags_locals = read_terragrunt_config(find_in_parent_folders(“locals.hcl”)) then pass value via a variable in your module:
module_variables.tf
variable "tags"{
  type = maps()
}

terragrunt.hcl
input = {
  tags = local.tags_locals.locals.tags
}
  • output the block of tags from the module
module_outptus.tf
output "tags"{
value = XXX
}

other terragrunt.hcl
dependency "source_tags" {
  config_path = "../XYZ"
}

inputs = {
  tags = dependency.source_tags.outputs.tags
}
1 Like