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

0

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?

shubham
preguntada hace 2 meses239 visualizaciones
1 Respuesta
1
Respuesta aceptada

Hello.

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.
https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html

Try finding the instance profile with the AWS CLI command below.
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iam/list-instance-profiles.html

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

If it is not needed, you can delete it using the following command.
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iam/delete-instance-profile.html

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

AWS CLI commands can be executed from CloudShell.
https://docs.aws.amazon.com/cloudshell/latest/userguide/welcome.html

profile picture
EXPERTO
respondido hace 2 meses
profile pictureAWS
EXPERTO
revisado hace 2 meses

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas