I have a use case where I would like to create many kubernetes provider definitions based on clusters, clusters are 100s of clusters e.g. I would like to create a map of providers, so that I can choose the providers from the for_each key, something like
provider_map = {
“cluster1” : provider “kubernetes” {
alias = “cluster1”
config_context = “cluster1”
}
“cluster2” : provider “kubernetes” {
alias = “cluster2”
config_context = “cluster2”
}
}
}
module “echo” {
for_each = toset( [“cluster1”, “cluster2”])
source = “<path_to_module_definition>”
name = “echo”
providers = {
kubernetes = provider_map[each.key]
}
cluster = each.key
}
Any help is really appreciated.