title: Dependency on local file creation
body: <p>I am setting up an EKS cluster with Terraform following the example <a href="https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/aws_auth.tf" rel="nofollow noreferrer">https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/aws_auth.tf</a> and I now have two Terraform files:</p>
  
  <p>kubeconfig.tf</p>
  
  <pre><code>resource "local_file" "kubeconfig" {
    content  = "${data.template_file.kubeconfig.rendered}"
    filename = "tmp/kubeconfig"
  }
  
  data "template_file" "kubeconfig" {
    template = "${file("template/kubeconfig.tpl")}"
  ...
  }
  </code></pre>
  
  <p>aws-auth.tf</p>
  
  <pre><code>resource "null_resource" "update_config_map_aws_auth" {
    provisioner "local-exec" {
      command = "kubectl apply -f tmp/config-map-aws-auth_${var.cluster-name}.yaml --kubeconfig /tmp/kubeconfig"
    }
  
    ...
   }
  </code></pre>
  
  <p>When I run this the local-exec command fails with </p>
  
  <blockquote>
    <p>Output: error: stat tmp/kubeconfig: no such file or directory</p>
  </blockquote>
  
  <p>On a second run it succeeds. I think that the file is created after local-exec tries to use it and local-exec should depend on the file resource. So I try to express the dependency by using interpolation (implicit dependency) like this:</p>
  
  <pre><code>resource "null_resource" "update_config_map_aws_auth" {
    provisioner "local-exec" {
      command = "kubectl apply -f tmp/config-map-aws-auth_${var.cluster-name}.yaml --kubeconfig ${resource.local_file.kubeconfig.filename}"
    }
  </code></pre>
  
  <p>But this always gives me </p>
  
  <blockquote>
    <p>Error: resource 'null_resource.update_config_map_aws_auth' provisioner
    local-exec (#1): unknown resource 'resource.local_file' referenced in
    variable resource.local_file.kubeconfig.filename</p>
  </blockquote>