Unable to connect to the server: getting credentials: exec: exec: “aws-iam-authenticator”: executable file not found in $PATH

Today I’m working on an EKS cluster in AWS. I’ve been used terraform to create AKS and GKE in the past. I wouldn’t say EKS creation is the most straight forward things in the world. I’ve been received multiple errors while doing the terraform eks creation. And the following is one of the error:

Unable to connect to the server: getting credentials: exec: exec: "aws-iam-authenticator": executable file not found in $PATH

By solving this problem, you have to install aws-iam-authenticator. If you are using a mac. you can run the following command:

brew install aws-iam-authenticator

Once you have done the installation, you have to make sure the following present under your kubeconfig file.

users:
- name: aws
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1alpha1
      command: aws-iam-authenticator
      args:
        - "token"
        - "-i"
        - "terraform-eks-demo"

re-run your kubectl command once you got the above step finished. And things should be work now.