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

1 minute read

I have an AWS Identity and Access Management (IAM) role that I want to assign to an Amazon Elastic Compute Cloud (Amazon EC2) instance.


Use either the Amazon EC2 console of the AWS Command Line Interface (AWS CLI) to assign a role. For more information, see Attach an IAM role to an instance.

If you use AWS Systems Manager, then 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.

If you receive errors when running AWS CLI commands, make sure that you’re using the most recent version of the AWS CLI.

Related information

Creating IAM roles

Tutorial: Get started with Amazon EC2 Linux instances

Using an IAM role to grant permissions to applications running on Amazon EC2 instances

I created an IAM role, but the role doesn't appear in the dropdown list when I launch an instance. What do I do?

AWS OFFICIALUpdated 10 months ago