IAM failed to create an EC2 role, no instance-profile ARN

0

Hello, I need to create a new EC2 role. According to the document, create a new role from IAM, and select EC2 in the AWS service. After the role is created, there is no instance-profile ARN. The IAM user is an administrator user, with full access. Is there a problem?

Doc: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html

jack
gefragt vor 4 Monaten412 Aufrufe
3 Antworten
0
Akzeptierte Antwort

I haven't created instance profiles via the console for a long time, but since you have your role already created, you can create an EC2 instance profile and attach it to the role you already created by launching CloudShell and running these commands. Replace "EC2RoleForMyServer" with the name of your role:

aws create-instance-profile --instance-profile-name EC2RoleForMyServer
aws add-role-to-instance-profile --instance-profile-name EC2RoleForMyServer --role-name EC2RoleForMyServer
EXPERTE
Leo K
beantwortet vor 4 Monaten
0

Hello,

If you use the AWS Management Console to create a role for Amazon EC2, the console automatically creates an instance profile and gives it the same name as the role and the console does not create an instance profile for a role that is not associated with Amazon EC2.

To attach the created IAM role to an EC2 instance, follow this guide: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html#attach-iam-role

After you attach the IAM role to an EC2 instance can use the below command to list the instance profile

aws iam list-instance-profiles

https://docs.aws.amazon.com/cli/latest/reference/iam/list-instance-profiles.html

profile picture
EXPERTE
beantwortet vor 4 Monaten
profile picture
EXPERTE
überprüft vor 4 Monaten
  • Yes, but after creation, there is no instance profile.

  • You have to attach it to an EC2 instance and then try to listing the instance profile using the CLI.

0

Thk, I tried to create an ec2 role again, this time, there was an instance profile. Maybe the console has some problem at that time.

jack
beantwortet vor 4 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen