title: How to deploy a Helm chart on AKS cluster with Terraform's local-exec?
body: <p>I have created an AKS cluster on Azure using Terraform.</p>
  
  <p>I have also set up my local workstation to be able to use kubectl, Helm and azurecli.</p>
  
  <p>I am trying to deploy a Helm chart via Terraform after the successful cluster creation, with the following code:</p>
  
  <pre><code>resource "local_file" "local-config-file" {
    content  = "${azurerm_kubernetes_cluster.k8s.kube_config_raw}"
    filename = "${path.module}/${var.cluster_name}.conf"
  }
  
  resource "null_resource" "set_kubeconfig" {
    provisioner "local-exec" {
      # working_dir = ""
      interpreter = ["C:/Program Files/Git/git-bash.exe"]
      command = "export KUBECONFIG=${path.module}/${var.cluster_name}.conf"
    }
  }
  
  resource "null_resource" "helm_drone" {
    provisioner "local-exec" {
      # working_dir = ""
      interpreter = ["C:/Program Files/Git/git-bash.exe"]
      command = "helm upgrade --install drone stable/drone"
    }
    depends_on = ["null_resource.set_kubeconfig"]
  }
  </code></pre>
  
  <p>The <code>local-config-file</code> is executed and the file is created correctly.</p>
  
  <p>However, Terraform reports that <code>set_kubeconfig</code> and <code>helm_drone</code> are executed and completed, </p>
  
  <pre><code>null_resource.set_kubeconfig: Creating...
  null_resource.set_kubeconfig: Provisioning with 'local-exec'...
  local_file.local-config-file: Creation complete after 0s (ID: d4c1df0df32052fb47437107957cb88b14d0d0d3)
  null_resource.set_kubeconfig (local-exec): Executing: ["C:/Program Files/Git/git-bash.exe" "export KUBECONFIG=C:\\Users\\k.demiris\\Documents\\Projects\\a2\\tfcluster/k8s.conf"]
  null_resource.set_kubeconfig: Creation complete after 1s (ID: 2649854281565879558)
  null_resource.helm_drone: Creating...
  null_resource.helm_drone: Provisioning with 'local-exec'...
  null_resource.helm_drone (local-exec): Executing: ["C:/Program Files/Git/git-bash.exe" "helm upgrade --install drone stable/drone"]
  null_resource.helm_drone: Creation complete after 0s
  </code></pre>
  
  <p>but when I check with <code>echo $KUBECONFIG</code> and <code>helm ls</code> I can see that nothing had happened.</p>
  
  <p>I am using Terraform on a Windows10 PC, so I am using <code>git-bash</code> as the interpreter.</p>
  
  <p>Does anyone have any experience with such a case?</p>
  
  <p><em>EDIT</em></p>
  
  <p>I tried this but didn't work:</p>
  
  <pre><code>resource "null_resource" "kubeconfig_and_helm" {
    provisioner "local-exec" {
      interpreter = ["C:/Program Files/Git/git-bash.exe"]
      command = "export KUBECONFIG=${path.module}/${var.cluster_name}-test.conf &amp;&amp; helm upgrade --install drone stable/drone"
    }
  }
  </code></pre>
  
  <p>and this...and also did not work:</p>
  
  <pre><code>resource "null_resource" "config_helm" {
    provisioner "local-exec" {
      interpreter = ["C:/Program Files/Git/git-bash.exe"]
      command = &lt;&lt;EOT
      export KUBECONFIG=${path.module}/${var.cluster_name}.conf &amp;&amp; \
      helm upgrade --install drone stable/drone
  EOT
    }
  }
  </code></pre>