×
Blog Cloud Computing Virtualization

Accessing S3 bucket through EC2 instance using IAM role

In this blog, we will show you the Steps to accessing S3 bucket through EC2 instance using the IAM role.

 

ENVIRONMENT OVERVIEW

 

  • An IAM role is an AWS identity that contains permission policies that can be assigned to a specific AWS user.
  • We have already created a few buckets under our subscription for this demo.

Accessing S3 bucket through EC2 instance using IAM role

 

  • Also, we have created an EC2 instance for this testing purpose.

CREATING IAM ROLE

 

  • Go-to IAM Management.

Accessing S3 bucket through EC2 instance using IAM role

 

  • Click on the Roles link.

 

  • Click on the create role button.

 

  • Select on EC2 service and click on Next for permission Window.

 

  • Search for S3 related permissions. We chose AmazonS3FullAccess for this demo.

 

  • No tags are given for this role. Then click on the Next button to review the selected settings.

 

  • Provide the name and description for your role and click on the Create Role button.

 

  • A new role has been created successfully.

 

 

ASSIGNING THE IAM  ROLE TO AN INSTANCE

 

  • Select the EC2 Instance and click on Actions.

Accessing S3 bucket through EC2 instance using IAM role

 

  • Go to Instance settings and click on Attach/Replace IAM Role option.

 

  • Select the IAM role from the drop-down list and click on Apply.

Accessing S3 bucket through EC2 instance using IAM role

 

  • The role has been attached successfully.

Accessing S3 bucket through EC2 instance using IAM role

 

VERIFICATION

 

  • Login into the EC2 instance and make sure that you have installed AWS CLI on that machine.

Accessing S3 bucket through EC2 instance using IAM role

 

 

  • Open the command prompt and list the available S3 buckets using below command.

aws s3 ls

Accessing S3 bucket through EC2 instance using IAM role

 

Thanks for reading this blog. We hope it was useful for you to learn about accessing the S3 bucket from an EC2 instance through IAM role.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.