Deleted roles are being shown in Instance's IAM Role List


The highlighted role "InstanceS3FullAccessRole" is not from my IAM Console and deleted a long back but still appears in this list. When applied, it has no effect which creates confusion. I tried creating new roles and deleting them also removes them from this list but not the "InstanceS3FullAccessRole". Instance IAM Role List Screenshot

How do I get rid of it? Is it a bug?

asked 2 months ago243 views
1 Answer
Accepted Answer


I think the instance profile remains.
In EC2, IAM roles are not attached directly, but to a resource called an instance profile.
Therefore, even if the IAM role is deleted, if the instance profile remains, it will be displayed when creating EC2.

Try finding the instance profile with the AWS CLI command below.

aws iam list-instance-profiles --query "InstanceProfiles"[]."InstanceProfileName"

If it is not needed, you can delete it using the following command.

aws iam delete-instance-profile --instance-profile-name InstanceS3FullAccessRole

AWS CLI commands can be executed from CloudShell.

profile picture
answered 2 months ago
profile pictureAWS
reviewed 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions