<p>I'm trying to use kubernetes-alpha provider in Terraform, but I have  &quot;Failed to construct REST client&quot; error message.
I'm using tfk8s to convert my yaml file to terraform code.</p>
<p>I make the seme declaration for the provider than kubernetes, and my kubernetes provider work correctely</p>
<pre><code>provider &quot;kubernetes-alpha&quot; {
  host                   = &quot;https://${data.google_container_cluster.primary.endpoint}&quot;
  token                  = data.google_client_config.default.access_token
  cluster_ca_certificate = base64decode(data.google_container_cluster.primary.master_auth[0].cluster_ca_certificate)
}

provider &quot;kubernetes&quot; {
  host                   = &quot;https://${data.google_container_cluster.primary.endpoint}&quot;
  token                  = data.google_client_config.default.access_token
  cluster_ca_certificate = base64decode(data.google_container_cluster.primary.master_auth[0].cluster_ca_certificate)
}
</code></pre>
<pre><code>resource &quot;kubernetes_manifest&quot; &quot;exemple&quot; {
  provider = kubernetes-alpha
  manifest = {
     # result of tfk8s
  }
}

</code></pre>
<p><a href="https://i.stack.imgur.com/rJoT9.png" rel="nofollow noreferrer">the error message</a></p>
<p>somebody can help ?</p>

<p>After some digging, I found that this resource requires a running kubernetes instance and config before the terraform plan will work properly.  Best stated in github here: <a href="https://github.com/hashicorp/terraform-provider-kubernetes-alpha/issues/199#issuecomment-832614387" rel="nofollow noreferrer">https://github.com/hashicorp/terraform-provider-kubernetes-alpha/issues/199#issuecomment-832614387</a></p>
<p>Basically, you have to have two steps to first terraform apply your main configuration to stand up kubernetes in your cloud, and then secondly terraform apply the CRD resource once that cluster has been established.</p>
<p>EDIT: I'm still trying to learn good patterns/practices for managing terraform config and found this pretty helpful. <a href="https://stackoverflow.com/questions/47708338/how-to-give-a-tf-file-as-input-in-terraform-apply-command">How to give a .tf file as input in Terraform Apply command?</a>. I ended up just keeping the cert manager CRD as a standard kubernetes manifest yaml that I apply per-cluster with other application helm charts.</p>
