1

I'm trying to DRY/parametrize the dependency block of my terragrunt file for my multi-environments setup.

I've these dependencies:

dependency "development" {
  config_path = "../../development/mandatory_resources" }

dependency "production" {
  config_path = "../../production/mandatory_resources" }

that I use this way:

inputs = {
  projects                    = {
    "dev"  = dependency.development.outputs.shared_resources_project_id,
    "prod" = dependency.production.outputs.shared_resources_project_id, 
  }
}

Assuming I've the map of available environments in this third dependency dependency.retrospect.outputs.available_environments (coming from an earlier terragrunt stage)

{
"dev" = "development",
"prod" = "production",
}

I'm wondering if there is a more elegant way to have the same results without writing twice the dependency block and/or hardcoding the environments in the inputs block (this would also allow me to scale to N enviroments without breaking the code). Is it possible with terragrunt? Perhaps using a for_each directive?

Gabriele B
  • 2,665
  • 1
  • 25
  • 40

0 Answers0