Unable to attach the Instance Profile Role to EC2

0

Hi,

I'm getting this error while trying to attach an instance profile role under EC2 -> Security -> modify IAM Role:-

Enter image description here

Failed to describe Instance Profiles
Failed to describe Instance Profiles. User: arn:aws:sts::336247864862:assumed-role/test/vkshs is not authorized to perform: iam:ListInstanceProfiles on resource: arn:aws:iam::336247864862:instance-profile/ because no identity-based policy allows the iam:ListInstanceProfiles action.

It seems like policy issue attached to my identity. Kindly suggest me its root cause and what policy is required here to fix it.

Regards, Vinod Kumar

1개 답변
1
수락된 답변

<<Remove your account id from the question error message at earliest.>>

You need to add following permission to your user/role for resource "instance profile name" through which you are logging to. this account:

Action:

 iam:ListInstanceProfiles

Policy to list EC2 and InstanceProfile would look like as below:

  {
        "Sid": "ListEc2AndListInstanceProfiles",
        "Effect": "Allow",
        "Action": [
            "iam:ListInstanceProfiles",
            "ec2:Describe*",
            "ec2:Search*",
            "ec2:Get*"
        ],
        "Resource": "*"
    }

Reference documentation

Once you add this to your role, you should be able to list instance profile.

Important point to note here is, AmazonEC2FullAccess managed policy doesn't have this permission however IAMReadOnlyAccess policy provides this access to all profiles, you may consider adding this policy too.

Hope you find this useful.

Abhishek.

profile pictureAWS
전문가
답변함 9달 전
profile pictureAWS
전문가
iBehr
검토됨 9달 전
  • Thanks, your solution worked however when I select this role and submit the button for 'Update IAM role' then I get this following error as well:-

    Failed to attach instance profile You are not authorized to perform this operation. Encoded authorization failure message: 0v498g_npaKBtWgAS6pJbH.......................

  • There are two things here, that you need to do:

    aws sts decode-authorization-message --encoded-message "encode failure message" -> This will give you the details of the failure.

    Please follow this re:Post Knowledge center article, Attach or replace instance profile also see if you have iam:PassRole permissions already as I have see that to be an issue as well.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠