title: How can we create same resource in multiple terraform providers?
body: <p>I am using terraform to create Kubernetes namespace. Sample below</p>
  <pre><code>resource &quot;kubernetes_namespace&quot; &quot;test1&quot; {
    metadata {
      name = local.ns_name
    }
  
  }
  </code></pre>
  <p>I am trying to create Blue/Green kind of deployment using terraform following this <a href="https://www.hashicorp.com/blog/terraform-feature-toggles-blue-green-deployments-canary-test" rel="nofollow noreferrer">link</a>. As part of it, I have created two kubernetes clusters now. One of blue and other for green side and there by now I have two kubernetes providers</p>
  <pre><code>provider &quot;kubernetes&quot; {
    alias                  = &quot;kubernetes_blue&quot;
  }
  
  provider &quot;kubernetes&quot; {
    alias                  = &quot;kubernetes_green&quot;
  }
  </code></pre>
  <p>I want to understand if there is a way, I can have some conditional on the <code>kubernetes_namespace</code> such that, depending on the flags <code>var.enable_green_side</code> and <code>var.enable_blue_side</code>, I can create the same namespace in multiple kubernetes clusters without having to repeat the entire resource block as follows</p>
  <pre><code>resource &quot;kubernetes_namespace&quot; &quot;test1&quot; {
    metadata {
      name = local.ns_name
    }
  
    provider = kubernetes.kubernetes_blue  
  }
  
  resource &quot;kubernetes_namespace&quot; &quot;test2&quot; {
    metadata {
      name = local.ns_name
    }
  
    provider = kubernetes.kubernetes_green  
  }
  </code></pre>
  <p>Thanks in advance.</p>