<p>I am using terraform cloud to provision some k8s infrastructure . </p>

<p>The issue i am facing is as terraform provider for kubernetes doesn't have the flexibility  of yaml file . i need to run some yaml files using <code>kubectl apply</code> This was okay when we run from local machine but when its from Terraform cloud it errors that </p>

<pre><code>kubectl is not installed 
</code></pre>

<p>Is there a way to solve this ? </p>

<p>possible install kubectl on terraform cloud </p>

<p>Thanks in advance </p>

Lib
<p>You can download the <code>kubectl</code> binary using a <code>null_resource</code> with the <code>local_exec</code> provisioner:</p>

<pre><code>resource "null_resource" "custom" {
  # change trigger to run every time
  triggers = {
    build_number = "${timestamp()}"
  }

  # download kubectl
  provisioner "local-exec" {
    command = "curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl &amp;&amp; chmod +x kubectl"
  }

  # run kubectl
  provisioner "local-exec" {
    command = "./kubectl apply -f deployment.yaml"
  }
}
</code></pre>

<p>Of course you also have to provide the target settings/credentials for <code>kubectl</code>, but that depends on your cluster provider, for example on AKS you would run <code>az aks get-credentials</code> before using <code>kubectl</code>.</p>
