title: Unable to obtain kubeconfig of an AWS EKS cluster in Go code
body: <p>I have created an AWS EKS cluster. In order to obtain its kubeconfig, I usually run <code>aws eks update-kubeconfig --name cluster-name --region us-west-2</code> using a shell.</p>
  
  <p>However, I now wish to obtain the kubeconfig in Go without having to run anything in the shell (the goal being to create and then manipulate an EKS cluster in a Go test). I am able to describe an EKS cluster using this code:</p>
  
  <pre><code>package main
  
  import (
      "fmt"
  
      "github.com/aws/aws-sdk-go/aws"
      "github.com/aws/aws-sdk-go/aws/session"
      "github.com/aws/aws-sdk-go/service/eks"
  )
  
  func main() {
      sess := session.Must(session.NewSession(&amp;aws.Config{
          Region: aws.String("us-west-2"),
      }))
      eksSvc := eks.New(sess, aws.NewConfig().WithRegion("us-west-2"))
  
  
      clusterOutput, err := eksSvc.DescribeCluster(&amp;eks.DescribeClusterInput{
          Name: aws.String("cluster-name"),
      })
      if err != nil {
          panic(err)
      }
      fmt.Printf("%#v\n", clusterOutput)
  }
  </code></pre>
  
  <p>After that, I currently have no idea about how could I get the kubeconfig of that cluster in order to then use it with the Go client for Kubernetes without having to use <code>aws eks</code> separately. </p>
  
  <p>I have checked the AWS documentation, AWS CLI codebase, and <code>eksctl</code> codebase with no luck so far. The connection to an EKS cluster is only documented in this webpage and it uses a shell: <a href="https://aws.amazon.com/premiumsupport/knowledge-center/eks-cluster-connection/" rel="noreferrer">https://aws.amazon.com/premiumsupport/knowledge-center/eks-cluster-connection/</a></p>
  
  <p>Any ideas?</p>