If you have received the following error while trying to issue commands to kubectl:

Unable to connect to the server: dial tcp: lookup

Then it may be due to your kube-config being out of date. You might just need to update the local kube-config.

How to update the local kube-config

Make sure to replace eu-west-1 with your cluster’s region, and replace cluster_name with the name of your EKS cluster.

aws eks --region "eu-west-1" update-kubeconfig --name "cluster_name"

How to update kube-config from Terraform state

aws eks --region $(terraform output -raw region) update-kubeconfig --name $(terraform output -raw cluster_name)

The above code makes use of the Terraform state’s output from when you generated the cluster.