Hi. I have a use-case that I haven't been able to figure out how to DRY up.
Consider the following directory layout.
โโโ account.hcl
โโโ develop
โย ย โโโ aws
โย ย โโโ us-west-2
โย ย โโโ app1
โย ย โย ย โโโ app
โย ย โย ย โย ย โโโ terragrunt.hcl
โย ย โย ย โโโ env.hcl
โย ย โย ย โโโ mysql
โย ย โย ย โย ย โโโ terragrunt.hcl
โย ย โย ย โโโ support
โย ย โย ย โโโ terragrunt.hcl
โย ย โโโ app2
โย ย โย ย โโโ app
โย ย โย ย โย ย โโโ terragrunt.hcl
โย ย โย ย โโโ env.hcl
โย ย โย ย โโโ mysql
โย ย โย ย โย ย โโโ terragrunt.hcl
โย ย โย ย โโโ support
โย ย โย ย โโโ terragrunt.hcl
โย ย โโโ region.hcl
โโโ production
โย ย โโโ aos
โย ย โย ย โโโ app1
โย ย โย ย โโโ app
โย ย โย ย โย ย โโโ secrets.yaml
โย ย โย ย โย ย โโโ terragrunt.hcl
โย ย โย ย โโโ mysql
โย ย โย ย โย ย โโโ terragrunt.hcl
โย ย โย ย โโโ support
โย ย โย ย โโโ terragrunt.hcl
โย ย โโโ aws
โย ย โย ย โโโ ca-central-1
โย ย โย ย โย ย โโโ app1
โย ย โย ย โย ย โย ย โโโ app
โย ย โย ย โย ย โย ย โย ย โโโ secrets.yaml
โย ย โย ย โย ย โย ย โย ย โโโ seed.json
โย ย โย ย โย ย โย ย โย ย โโโ terragrunt.hcl
โย ย โย ย โย ย โย ย โโโ mysql
โย ย โย ย โย ย โย ย โย ย โโโ terragrunt.hcl
โย ย โย ย โย ย โย ย โโโ s3
โย ย โย ย โย ย โย ย โย ย โโโ terragrunt.hcl
โย ย โย ย โย ย โย ย โโโ sqs
โย ย โย ย โย ย โย ย โโโ terragrunt.hcl
โย ย โย ย โย ย โโโ app2
โย ย โย ย โย ย โโโ region.hcl
โย ย โย ย โโโ eu-west-2
โย ย โย ย โย ย โโโ region.hcl
โย ย โย ย โโโ us-west-2
โย ย โย ย โโโ region.hcl
โย ย โย ย โโโ uw
โย ย โย ย โโโ app
โย ย โย ย โโโ mysql
โย ย โโโ azure
โย ย โโโ gcp
โโโ staging
โย ย โโโ us-west-2
โย ย โโโ preview
โย ย โย ย โโโ app
โย ย โย ย โย ย โโโ terragrunt.hcl
โย ย โย ย โโโ env.hcl
โย ย โย ย โโโ mysql
โย ย โย ย โย ย โโโ terragrunt.hcl
โย ย โย ย โโโ support
โย ย โย ย โโโ terragrunt.hcl
โย ย โโโ region.hcl
โโโ terragrunt.hcl
In each of the ./app/terragrunt.hcl you will find:
include {
path = find_in_parent_folders()
}
locals {
env = read_terragrunt_config(find_in_parent_folders("env.hcl"))
}
dependency "mysql" {
config_path = "../mysql"
}
dependency "support" {
config_path = "../support"
}
terraform {
source = "/path/to/modules//app"
}
inputs = {
release_name = local.env.locals.environment
values = {
"inboxQueue" = dependency.support.inbox_queue_url
"outboxQueue" = dependency.support.outbox_queue_url
"externalDatabase.host" = dependency.mysql.outputs.host
"externalDatabase.port" = dependency.mysql.outputs.port
"externalDatabase.dbName" = dependency.mysql.outputs.db_name
"externalDatabase.user" = dependency.mysql.outputs.username
}
secrets = {
"externalDatabase.password" = dependency.mysql.outputs.password
}
}
Ideally, I would be able to DRY up the usage of dependency and inputs that utilizes the outputs from said dependencies.
Is this possible?
This is not possible yet. You sort of can do this with read_terragrunt_config, but it is not recommended due to https://github.com/gruntwork-io/terragrunt/issues/1128.
We plan on supporting this use case in the upcoming imports block feature but we have not had the chance to fully implement it yet. We will update this ticket when that is implemented.
Most helpful comment
This is not possible yet. You sort of can do this with
read_terragrunt_config, but it is not recommended due to https://github.com/gruntwork-io/terragrunt/issues/1128.We plan on supporting this use case in the upcoming imports block feature but we have not had the chance to fully implement it yet. We will update this ticket when that is implemented.