Kubernetes provider depends on to be created local_file

Hi everyone,

I browsed through a lot a posts without finding specific answer to my problem.

I would like to bootstrap a kubernetes cluster and create a kubernetes deployement in it in one go, thus leading to dependency problem since kubernetes provider needs config_path to exist during terraform plan phase… which will be created after apply phase.

I can’t wrapped my head around this.

What is the appropriate pattern to make provider wait for resource ?

Example :

resource "local_file" "plop" {                                                                                                                    
  filename = "plop"                                                                                                                               
provider "kubernetes" {                                                                                                                           
  config_path = local_file.plop.filename                                                                                                          
resource "kubernetes_namespace" "ns" {                                                                                                            
  metadata {                                                                                                                                      
    name = "dummy-ns"                                                                                                                                 

Should trigger

Error: could not open kubeconfig "plop": stat plop: no such file or directory