AWS Certified DevOps Engineer - Professional: Troubleshooting Role Attachment Issue

Why Can't You Use the "DemoRole" with Your EC2 Instance?

Prev Question Next Question

Question

You have a set of EC2 instances hosted in AWS.

You have created a policy and attached it to a role named "DemoRole" created through the CLI.

But you are unable to use that role with an instance.

Why is this the case?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Answer - A.

An instance profile is a container for an IAM role that you can use to pass role information to an EC2 instance when the instance starts.

Option B is invalid because you can associate a role with an instance.

Option C and D are invalid because using users or user groups is not a pre-requisite.

For more information on instance profiles, please visit the link:

http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html

The correct answer is A. You need to create an instance profile and associate it with that specific role.

Explanation: AWS Identity and Access Management (IAM) roles are a way to grant permissions to entities such as EC2 instances, Lambda functions, or other AWS services. An instance profile is a container for an IAM role that you can use to pass role information to an EC2 instance when the instance starts.

To use an IAM role with an EC2 instance, you need to create an instance profile and associate it with the role. An instance profile is essentially a container for the role that can be used by EC2 instances when they need to access AWS resources.

When you create an instance profile, AWS creates a new IAM role with the same name as the instance profile, and grants the necessary permissions to that role. You can then attach the instance profile to an EC2 instance at launch time, and the instance will have the permissions granted by the associated role.

Therefore, in this scenario, the reason why the role cannot be used with an instance is because an instance profile has not been created and associated with the role. Once an instance profile is created and associated with the role, it can be attached to an EC2 instance and used to grant the instance permissions to access AWS resources.