×
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

 

  • 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.

Accessing S3 bucket through EC2 instance using IAM role

CREATING IAM ROLE

 

  • Go-to IAM Management.

Accessing S3 bucket through EC2 instance using IAM role

 

  • Click on Roles link.

Accessing S3 bucket through EC2 instance using IAM role

 

  • Click on create role button.

Accessing S3 bucket through EC2 instance using IAM role

 

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

Accessing S3 bucket through EC2 instance using IAM role

 

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

Accessing S3 bucket through EC2 instance using IAM role

 

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

Accessing S3 bucket through EC2 instance using IAM role

 

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

Accessing S3 bucket through EC2 instance using IAM role

 

  • A new role has been created successfully.

Accessing S3 bucket through EC2 instance using IAM role

 

 

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.

Accessing S3 bucket through EC2 instance using IAM role

 

  • 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.