Search code examples
amazon-web-servicesamazon-ec2amazon-iamroles

Attach IAM role to multiple EC2 instances


There seems to be plenty of documentation that outlines making a role with its corresponding policies and then attaching that to a new or pre-existing (single) EC2 instance. However, when you have many instances and the task it to attach a role to all of those instances, I can't find or figure a way that avoid doing the process one-by-one.

So, how does one attach an IAM role to multiple already-launched EC2 instances efficiently?


Solution

  • You'd have to do this one by one. It would generally be attached at launch but you can do it afterwards.

    Programatically looping would probably be the most efficient