Interview Prep/GitHub Actions/OIDC & Cloud Authentication

`error: You must be logged in to the server (Unauthorized)` from kubectl on EKS after OIDC login.

AdvancedTroubleshootingOIDC & Cloud Authentication
Answer

Likely causes → The IAM role is not mapped into the cluster: no EKS access entry (or aws-auth ConfigMap entry), wrong cluster or region in update-kubeconfig, or the cluster's authentication mode is CONFIG_MAP only and you created access entries.

Diagnose →

aws sts get-caller-identity
aws eks describe-cluster --name shack --query cluster.accessConfig
aws eks list-access-entries --cluster-name shack

Fix →

aws eks create-access-entry --cluster-name shack --principal-arn arn:aws:iam::111122223333:role/gha-deploy-prod
aws eks associate-access-policy --cluster-name shack --principal-arn arn:aws:iam::111122223333:role/gha-deploy-prod \
  --policy-arn arn:aws:eks::aws:cluster-access-policy/AmazonEKSEditPolicy \
  --access-scope type=namespace,namespaces=shack-prod

Prevent → Manage access entries in Terraform alongside the role.

All GitHub Actions questions Roadmap: GitHub Actions

More on OIDC & Cloud Authentication