<p>I want to create a secret in several k8s clusters in the Google Kubernetes Engine using the Terraform.</p>

<p>I know that I can use "host", "token" and some else parameters in "kubernetes" provider,  but I can describe these parameters only once, and I don’t know how to connect to another cluster during the file of terraform.</p>

<p>My question is how to create a secret (or do other operations) in multiple k8s cluster via Terraform. Maybe you know some tools on github or other tips for doing via single terraform file?</p>

Stepan K.
<p>You can use alias for provider in terraform like described in <a href="https://www.terraform.io/docs/configuration/providers.html#alias-multiple-provider-instances" rel="noreferrer">documentation</a></p>

<p>So you can define multiple providers for multiple k8s clusters and then refer them by alias.</p>

<p>e.g.</p>

<pre><code>provider "kubernetes" {
  config_context_auth_info = "ops1"
  config_context_cluster   = "mycluster1"
  alias = "cluster1"
}

provider "kubernetes" {
  config_context_auth_info = "ops2"
  config_context_cluster   = "mycluster2"
  alias = "cluster2"
}

resource "kubernetes_secret" "example" {
  ...
  provider = kubernetes.cluster1
}
</code></pre>
