Skip to main content
In this guide, we’ll configure cross-account access between a Production AWS account (owns an S3 log bucket) and a Development AWS account (hosts a Log Analysts group). This setup enables secure, temporary access to logs without sharing long-term credentials.

Scenario

Our objective is to let the Log Analysts group assume a role in the Production account to retrieve logs.

High-Level Architecture

  1. Create an IAM Role in the Production Account
  2. Attach an inline S3 policy to that role
  3. Update the S3 Bucket Policy to trust the role
  4. Assume the role from the Development Account and verify access
The image is a diagram showing a request to provide log access to a Log Analysts group, involving a production account with an S3 bucket and a dev account with a log access role.

Cross-Account Access Components

The image explains IAM Cross Account Access Capability, highlighting the implementation of cross-account access, the need for a trust relationship, role assumption by users, and the security benefits of resource isolation.
Be explicit in your trust policy to avoid granting unintended access. Restrict Principal to specific IAM roles or account IDs.

Demo Walkthrough

Follow these steps to implement and test cross-account S3 access.

1. Create the IAM Role in Production

Create a trust policy (trust-policy.json):
Use the AWS CLI to create the role:

2. Attach an Inline S3 Access Policy

Define s3-access-policy.json:
Attach it to the role:

3. Update the S3 Bucket Policy

Create or edit your bucket policy (bucket-policy.json):
Apply it:
Ensure the bucket policy’s Principal matches the exact ARN of the role. Using wildcards may expose your bucket to unintended access.

4. Assume the Role and Verify Access

From the Development account, assume the role:
Export temporary credentials:
List and retrieve logs:

References

Watch Video