14
votes

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?

2
You can attach only one role to ec2 instance. Refer this amazon document: docs.aws.amazon.com/AWSEC2/latest/UserGuide/…. Instead create 2 managed policies and attach them to the same IAM Role. Attach that IAM Role to the EC2 instance.krishna_mee2004

2 Answers

19
votes

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.
-2
votes

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: