I have the following example code:
module "eks" {
source = ...
}
provider "kubernetes" {
host = module.eks.cluster_endpoint
...
}
Tthe “eks” module requires the “kubernetes” provider, and the “kubernetes” provider requires outputs derived from the “eks” module. I know this isn’t ideal, but it is what it is.
I have a need to create X clusters per environment. The way I typically handle this using for_each on a module in the main stack:
module "eks" {
for_each = var.eks_clusters
...
}
In order for this to work, you also need to create a separate “kubernetes” provider per “eks” instantiation. But, Terraform doesn’t support iteration (for_each, etc) on providers. So, I’m left with the inability to easily provision multiple clusters per environment without separate “module eks” blocks. This is further complicated by the fact that one environment may need only 1 EKS cluster, but another environment may need >1.
How would you handle this in Terraspace?