I have module to create k8s namespaces in main.tf like this:
module “kubesetup” {
for_each = toset(var.namespaces_tenants)
tenant = each.value
providers = { kubernetes = kubernetes.kubeconfig }
source = “./modules/kubesetup”
}
Then I have another module in which I can not use depends_on because it has provider configs inside that module. I tried to use this in module B call in main.tf: namespaceok = module.kubesetup to create dependency between them, module B fails if kubesetup has not created all required namespaces in k8s first. Now when I run this setup I get error because of namespaces has not been created before module B executes? From logs I can see that kubesetup did start before module B but it did not finish. I assume that this is because of for_each loop, so first call to loop might be finished but not all iterations. So how can I make sure that all namespaces are created by module kubesetup before executing module B?