25

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?

s5s
  • 11,159
  • 21
  • 74
  • 121
  • 20
    You can attach only one role to ec2 instance. Refer this amazon document: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html. Instead create 2 managed policies and attach them to the same IAM Role. Attach that IAM Role to the EC2 instance. – krishna_mee2004 Jan 30 '18 at 18:54

2 Answers2

34

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.
bolov
  • 72,283
  • 15
  • 145
  • 224
-2

On Attach the two policies to one IAM Role.(Updated Dec 2019)

  • Under IAM > Access management > Policies

  • Create two Policies. Docs

  • Under IAM > Access management > Roles

  • Select the IAM role you want to attach the policies to

    • Alternatively Create a new IAM role Docs
  • Select the > Permissions tab then > Attach Policies Docs

  • Search and select the policies you would like to attach to that role Docs

  • Attach your role to the EC2 instance Docs .

On the navigation pane, choose > Instances.

Select the instance, choose Actions > Instance Settings> Attach/Replace IAM role.

References:

iamcaleberic
  • 913
  • 8
  • 12
  • I can't see how to attach a role to a group. Do you do it via the roles menu or groups menu? I've only been able to attach users to groups. – s5s Jan 30 '18 at 19:02
  • I can't see how to attach a group to an ec2 instance as a role. When I choose "Attach/Replace IAM Role", I only get an option of picking a role, not a group. – s5s Jan 30 '18 at 19:04
  • There is no option to add a role to a group. – s5s Jan 30 '18 at 19:11