<p>I am trying to utilize Rancher Terraform provider to create a new RKE cluster and then use the Kubernetes and Helm Terraform providers to create/deploy resources to the created cluster. I'm using this <a href="https://registry.terraform.io/providers/rancher/rancher2/latest/docs/resources/cluster_v2#kube_config" rel="noreferrer">https://registry.terraform.io/providers/rancher/rancher2/latest/docs/resources/cluster_v2#kube_config</a> attribute to create a local file with the new cluster's kube config.
The Helm and Kubernetes providers need the kube config in the provider configuration: <a href="https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs" rel="noreferrer">https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs</a>. Is there any way I can get the provider configuration to wait for the local file being created?</p>

<p>Generally speaking, Terraform always needs to evaluate provider configurations during the planning step because providers are allowed to rely on those settings in order to create the plan, and so it typically isn't possible to have a provider configuration refer to something created only during the apply step.</p>
<p>As a way to support bootstrapping in a situation like this though, this is one situation where it can be reasonable to use the <code>-target=...</code> option to <code>terraform apply</code>, to plan and apply only sufficient actions to create the Rancher cluster first, and then follow up with a normal plan and apply to complete everything else:</p>
<pre><code>terraform apply -target=rancher2_cluster_v2.example
terraform apply
</code></pre>
<p>This two-step process is needed only for situations where the <code>kube_config</code> attribute isn't known yet. As long as this resource type has convergent behavior, you should be able to use just <code>terraform apply</code> as normal unless you in future make a change that requires replacing the cluster.</p>
<p>(This is a general answer about provider configurations refering to resource attributes. I'm not familiar with Rancher in particular and so there might be some specifics about that particular resource type which I'm not mentioning here.)</p>
