sts:AssumeRole.
Example accounts and principals used in this guide:
- Account A (target account): account ID
635573991785— contains the roleCrossAccountS3ReadRole - Account B (caller account): account ID
466456867028— contains the IAM userArnold2 - In Account A there is also a local IAM user
Anu(main account operator)
Overview: trust policy vs permission policy
- Trust policy (attached to the role in Account A) controls who may assume the role.
- Permission policy (attached to the role in Account A) controls what the role can do after being assumed.
- The IAM user in Account B must also be granted
sts:AssumeRoleon the role ARN so they can initiate the assume operation.
1) Create the cross-account role (in Account A)
- In Account A, open the AWS Console → IAM → Roles → Create role.
- When prompted for a trust policy, choose the option that lets you provide a custom trust policy (or paste JSON).
Arnold2 in Account B to assume the role. Replace the account ID and user name with your actual values:
- Attach the role’s permissions policy. For this demo we attach the managed policy
AmazonS3ReadOnlyAccessso the role can list buckets and read objects. - Give the role a descriptive name, for example
CrossAccountS3ReadRole, then create it.

2) Allow the IAM user in Account B to assume the role
In Account B, open the IAM console and select the IAM userArnold2. Add an inline policy (or managed policy) that permits sts:AssumeRole on the role ARN in Account A.
Example inline policy JSON for Arnold2 (attach in Account B):

Arnold2 has the required permission to call sts:AssumeRole on the CrossAccountS3ReadRole in Account A.
3) Switch role in the Console to assume the role
From the AWS Console while signed in asArnold2 (Account B):
- Open the account / user menu and choose Switch Role.
- Enter the Account ID of Account A (
635573991785) and the role nameCrossAccountS3ReadRole. - Optionally set a display label and color, then click Switch Role.


4) Verify S3 access with the assumed role
Once you’ve assumedCrossAccountS3ReadRole, open the S3 console. Because the role has AmazonS3ReadOnlyAccess, you can list buckets and view objects that the role is allowed to access. You will not be able to perform write operations (such as creating buckets) because the role only has read permissions.



AmazonS3ReadOnlyAccess:

Optional: Assume the role programmatically (AWS CLI example)
You can also assume the role using the AWS CLI or SDKs. Example CLI command: aws sts assume-role—role-arn arn:aws:iam::635573991785:role/CrossAccountS3ReadRole
—role-session-name Arnold2Session This returns temporary credentials (AccessKeyId, SecretAccessKey, SessionToken). You can export them into environment variables to run subsequent CLI commands under the assumed role. Example (bash):
Troubleshooting checklist
- Ensure the trust policy on the role in Account A includes the correct principal ARN (user, role, or account).
- Confirm
Arnold2in Account B has an IAM policy that allowssts:AssumeRoleon the role ARN in Account A. - Verify the role in Account A has the correct permission policy attached (e.g.,
AmazonS3ReadOnlyAccess). - If using the Console switch-role feature, confirm you provided the exact Account ID and role name.
- Check CloudTrail and IAM error messages for
AccessDenieddetails if assumption fails.
Avoid granting broad trust (for example,
Principal: "*") unless absolutely required. Always scope trust and permissions to the minimum set of principals and actions needed.Summary
- The trust policy on the role (Account A) defines who can assume it — in this example
arn:aws:iam::466456867028:user/Arnold2. - The permission policy attached to the role defines what actions the role may perform after being assumed — here,
AmazonS3ReadOnlyAccess. - The IAM user in Account B must have an IAM policy allowing
sts:AssumeRoleon the role ARN in Account A. - You can assume the role using the Console (Switch Role) or programmatically using AWS CLI/SDKs with STS.
Best practice: grant the least privilege necessary. Use specific principals in trust policies and attach only the required permissions to roles.
Links and references
- IAM roles for cross-account access — AWS Documentation
- AssumeRole — AWS STS API
- AmazonS3ReadOnlyAccess — AWS Managed Policy