This post explains how to attach an IAM role to an EC2 instance. For
attaching a role to EC2 instance, it must be in either
running or stopped state.
Attach IAM role to EC2 instance
Create IAM Role
1. Navigate to IAM console
2. In the navigation pane, choose Roles,
3. On the Select trusted entity page, choose AWS service and for use case
select EC2. Click on Next.
4. On the Add permissions page, select the policy as per the requirement,
for this tutorial purpose we are using AmazonS3ReadOnlyAccess. Click on
5. Enter the role name and description and click on
Attach role to EC2 Instance
6. Navigate to EC2 console
7. Select the instance, choose Actions,
Security, Modify IAM role.
8. Select the IAM role created previously and click on