<p>I am working on a system that is spread across both Digital Ocean and AWS.  Their Node.js instances are on a Kubernetes cluster on Digital Ocean and their databases and S3 spaces are hosted on AWS.  I was able to connect to the Kubernetes cluster using kubectl.  Then, I was able to do a 'terraform init' with no issues.  But, when I tried to do a 'terraform plan', I got this error.</p>

<p>Error: Error retrieving Kubernetes cluster: GET <a href="https://api.digitalocean.com/v2/kubernetes/clusters/1234" rel="nofollow noreferrer">https://api.digitalocean.com/v2/kubernetes/clusters/1234</a>: 401 Unable to authenticate you.</p>

<p>I am new to both Kubernetes and Terraform.  Does Terraform expect the Kubernetes config information to be in a different place then where kubectl expects it?  </p>

mikeb
<p>You need a token so that Digital Ocean’s servers know that you have permission to access your account.
Follow the steps in the instruction <a href="https://www.digitalocean.com/docs/api/create-personal-access-token/" rel="nofollow noreferrer">creating-access-token</a> and copy the token to your clipboard.Remember to store it as an environment variable:
<code>export TF_VAR_do_token=your-token</code>.</p>
<p>Set environment variables:</p>
<pre><code>export TF_VAR_do_token=your_digital_ocean_token

export TF_VAR_do_cluster_name=your_cluster_name
</code></pre>
<p>Otherwise problem is with the API token. Create a new token and then the operation will succeeded.</p>
<p>Useful blog article about setting up <a href="https://web.archive.org/web/20190314161613/https://ponderosa.io/blog/kubernetes/2019/03/13/terraform-cluster-create/" rel="nofollow noreferrer">Kubernetes cluster wit Digital Ocean and Terraform</a>.</p>
