How to Grant EC2 Instance Access to S3 Bucket in Another AWS Account

Fabiano Becatini
5 min readFeb 18, 2024
Grant EC2 Instance Access to S3 Bucket in Another AWS Account

One common use case for EC2 and S3 is to store and retrieve files from S3 buckets using EC2 instances.

What if the S3 bucket is in another AWS account?

This blog post will provide a step-by-step guide on how to grant an AWS EC2 instance access to an AWS S3 bucket in a different AWS account.

To achieve this, you will need to create an IAM (Identity and Access Management) role in AWS Account B pointing to Account A.

Then, you will create another IAM role in Account A that will be your instance profile, and attach that IAM role to the EC2 instance in your AWS Account A.

Finally, you will need to validate the permissions on your S3 bucket.

PRE-REQUISITES

I will assume you have an AWS environment already setup with the scenario below:

If you want to learn more about IAM Policies

--

--