Search code examples
amazon-web-serviceskuberneteskubectl

User: arn:aws:iam::xxxxxxxxxxxx:user/<AWS_USERNAME> is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::xxxxxxxxxxxx:role/role_name


My company has given me a replacement laptop because the previous one has died. Using aws configure, I have configured AWS and also downloaded and added kubectl to the path. I have updated the kubectl config using

aws eks update-kubeconfig \
    --region us-west-2 \
    --name my-app-prd \
    --role-arn arn:aws:iam::xxxxxxxxxxxx:role/role_name

I changed the cluster using

kubectl config use-context arn:aws:eks:us-west-2:xxxxxxxxxxxx:cluster/my-app-prd

When I run

kubectl get svc

I get the following error message

An error occurred (AccessDenied) when calling the AssumeRole operation: User: arn:aws:iam::xxxxxxxxxxxx:user/<AWS_USERNAME> is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::xxxxxxxxxxxx:role/role_name E0201 09:59:49.896242 7160 memcache.go:265] couldn't get current server API group list: Get "https://...eks.amazonaws.com/api?timeout=32s": getting credentials: exec: executable aws failed with exit code 254


Solution

  • Run the command aws eks --region us-west-2 update-kubeconfig --name my-app-prd to update the kubectl config and then run kubectl get svc