Hello,
I’m wondering if there is any way to get for_each
and providers
to work together within a module block.
At the moment I have to do this:
module "foo_blue" {
...
providers = {
kubernetes = kubernetes.blue
}
}
module "foo_green" {
...
providers = {
kubernetes = kubernetes.green
}
}
What I would like to do is something like this:
module "foo" {
...
for_each = {
blue = {}
green = {}
}
providers = {
kubernetes = "kubernetes.${each.key}"
}
}
The above doesn’t work due to the providers
input value being invalid.
Is it possible to get any form of dynamic value selection into the providers
map?
When provisioning and configuring multiple kubernetes clusters within a single Terraform root module, I often have a hard time dealing with providers.
If users were allowed to put logic (eg. functions or if/else) in the provider
definition, this would be a lot easier.