Interview Prep/AWS/ECS, EKS, ECR and Lambda

`kubectl get pods` returns `error: You must be logged in to the server (Unauthorized)` on a new EKS cluster.

BeginnerTroubleshootingECS, EKS, ECR and Lambda
Answer

Likely causes → Your IAM principal is not mapped into the cluster. Only the cluster creator gets admin automatically (and only if bootstrap admin was on). Other causes: the kubeconfig uses a different profile or role than the one that has an access entry.

Diagnose →

aws sts get-caller-identity
aws eks update-kubeconfig --name prod --region us-east-1
aws eks list-access-entries --cluster-name prod
aws eks describe-cluster --name prod --query 'cluster.accessConfig'

Fix →

aws eks create-access-entry --cluster-name prod --principal-arn arn:aws:iam::111111111111:role/platform-admin
aws eks associate-access-policy --cluster-name prod --principal-arn arn:aws:iam::111111111111:role/platform-admin \
  --policy-arn arn:aws:eks::aws:cluster-access-policy/AmazonEKSClusterAdminPolicy --access-scope type=cluster

Prevent → Use authentication mode API with access entries managed in IaC, not the aws-auth ConfigMap.

aws All AWS questions Roadmap: EKS, ECS & serverless on AWS

More on ECS, EKS, ECR and Lambda