Search code examples
amazon-web-serviceskubernetesamazon-iamamazon-ekseksctl

AWS EC2 unable to access EKS


I have a role which has full privilege to access EKS, Ec2, IAM which is attached to an Ec2 Instance.

I am trying to access my EKS cluster from this Ec2 Instance. I did add the Ec2 instance arn like below to the Trusted relationship of the role which the instance assumes as well. However, still I get the error like below when trying to access the cluster using kubectl from cli inside the Ec2 instance.

I have tried below to obtain the kube config written to the instance hoe directory from which I execute these commands.

aws sts get-caller-identity

$ aws eks update-kubeconfig --name eks-cluster-name --region aws-region --role-arn arn:aws:iam::XXXXXXXXXXXX:role/testrole

Error I'm getting:

error occurred (AccessDenied) when calling the AssumeRole operation: User: arn:aws:sts::769379794363:assumed-role/dev-server-role/i-016d7738c9cb84b96 is not authorized to perform: sts:AssumeRole on resource xxx

Solution

  • Community wiki answer for better visibility.

    The problem is solved by taking a good tip from the comment:

    Don't specify role-arn if you want it to use the instance profile.

    OP has confirmed:

    thanks @jordanm that helped