How do I assign an existing IAM role to an EC2 instance?

Last updated: 2020-09-18

I have an Identity and Access Management (IAM) role that I want to assign to an Amazon Elastic Compute Cloud (Amazon EC2) instance. How can I do this?


  1. From the Amazon EC2 console, choose Instances from the navigation pane.
  2. Select the instance that you want to attach the IAM role to.
  3. For Actions, choose Instance Settings, Attach/Replace IAM role.
  4. For IAM role, choose your IAM role, and then choose Apply.
  5. Choose Close.

The IAM role is now assigned to your EC2 instance.

Note: If you use AWS Systems Manager, wait for AWS Systems Manager Agent (SSM Agent) to detect the new IAM role, or restart SSM Agent. For more information, see Setting up AWS Systems Manager.