Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon EC2 instances multiple IAM roles

At the moment I have 2 AWS IAM roles and each has 1 policy, call them Policy-A and Policy-B. I would like to attach both roles to an EC2 instance. Alternative is to create a new role which has both Policy-A and Policy-B.

Can I attach more than 1 IAM role to an EC2 instance?

like image 775
s5s Avatar asked Jan 30 '18 18:01

s5s


People also ask

Can EC2 instance have multiple IAM roles?

An instance profile can contain only one IAM role. This limit cannot be increased.

Can we attach multiple roles to instance profile?

An instance profile can contain only one IAM role, although a role can be included in multiple instance profiles. This limit of one role per instance profile cannot be increased. You can remove the existing role and then add a different role to an instance profile.

Can IAM user have multiple roles?

Technically, you can assume multiple IAM roles at the same time but the permissions will not be aggregated. Assuming an IAM role doesn't change who you are or what permissions you have.

Can an AWS service have multiple roles?

Each instance profile can contain only one role, and that limit cannot be increased. If you create the role in the AWS Management Console, the instance profile is created for you with the same name as the role. For more information about instance profiles, see Using instance profiles.


1 Answers

This is a comment by krishna_mee2004, but it should be an answer:

You can attach only one role to ec2 instance. Refer this amazon document: IAM Roles for Amazon EC2. Instead:

  • create 2 managed policies
  • attach them to the same IAM Role.
  • Attach that IAM Role to the EC2 instance.
like image 173
bolov Avatar answered Sep 19 '22 05:09

bolov