Hi,
I have a requirement where I need dynamically lookup variable names,
So I have variables like this,
variable "app_example_secret" {
type = string
description = "API Secret"
sensitive = true
}
Assuming one of the each.key is “app_example”, how do I refer to the variable “app_example_secret” with an “each.key” reference?
Code that is looking for a such an interpolation is,
"KeySecret" : try(module.app_yaml.files[each.key].app.exists, "var.${each.key}_secret", local.secret[each.key])
Obviously the above doesn’t work as it creates a static
+ KeySecret = "var.app_example_secret"
I tried referring to it like this,
"${var."${each.key}_key"}"
That throws “An attribute name is required after a dot.” error.
Appreciate your help on this.