We can create an IAM role with access to S3 APIs as follows:
- Go to the IAM dashboard.
- Click on Roles from the left sidebar.
- Click on Create role.
- Select EC2 as the service that will use this role and click Next: Permissions.
- Select AmazonS3FullAccess and click Next: Tags.
- Optionally, add any tags and click Next: Review.
- Give the role a name (for example, MyS3AccessRole) and click Create role.
We can associate the role with an EC2 instance as follows:
- Go to the EC2 dashboard.
- Click on Instances from the left sidebar.
- Select our private instance, click on Actions, click on Instance Settings, and click on Attach/Replace IAM Role:
- Select our new IAM role and click Apply:
We should get a success message.