I am currently trying to assign an IAM role to one of my instances via AWS CLI. The CLI is running on a linux instance that currently has Admin privileges for EC2 (AmazonEC2FullAccess policy).
I am trying to run the following command:
aws ec2 associate-iam-instance-profile --instance-id i-0xxxxxxxxxxx4 --iam-instance-profile Name=AmazonSSMRoleForInstancesQuickSetup
But I get the following error:
An error occurred (UnauthorizedOperation) when calling the AssociateIamInstanceProfile operation: You are not authorized to perform this operation. Encoded authorization failure message: <hash>
I am struggling to find what policy is required to allow this action from my AWS CLI instance. I even tried giving it the nuclear IAMFullAccess
policy but I still got permission denied.
I've been trying to google it for a while now but I wasn't able to solve this problem by myself, please help.
Could you please tell me what policy is required in order to allow my instance to run aws ec2 associate-iam-instance-profile
?
Additionally, is there a quick/easy way to find out what permissions are required to use certain aws cli functions?