Understanding Cross-Account IAM Roles in AWS
Last updated
Was this helpful?
Last updated
Was this helpful?
A cross-account IAM role is a mechanism in AWS that enables you to grant access to resources in one AWS account (the trusting account) to users or services in another AWS account (the trusted account). This is a fundamental building block for implementing the principle of least privilege in multi-account AWS environments.
The trust policy is a JSON document attached to the role that defines which entities (AWS accounts, services, or users) can assume the role. For example:
The permission policy defines what actions the role can perform on which resources. This policy determines the actual permissions granted to users who successfully assume the role:
Users or roles in the trusted account need a permission policy allowing them to assume the cross-account role. This policy must be attached to the IAM users/roles that need to assume the cross-account role:
Initial Setup
Trusting account creates an IAM role with trust and permission policies
Trusted account attaches AssumeRole permissions to relevant users/roles
No additional roles need to be created in the trusted account
Role Assumption
Users/services in the trusted account use AWS Security Token Service (STS)
STS verifies both the trust relationship and the user's permission to assume roles
If valid, STS returns temporary security credentials
Resource Access
The temporary credentials allow access to resources as defined in the permission policy
These credentials automatically expire after their defined duration (15 minutes to 12 hours)
Central Security Management
A security team in one account manages security tools across multiple accounts
Enables centralized logging, monitoring, and compliance oversight
Application Development
Developers access resources across development, staging, and production accounts
Maintains separation of concerns while enabling necessary access
Managed Services
Third-party services require access to resources in your AWS account
Provides controlled, time-limited access without sharing long-term credentials
External ID Usage
Implement external IDs in trust policies to prevent confused deputy problems
Especially important when granting access to third parties
Permission Boundaries
Set clear permission boundaries to limit maximum possible permissions
Use AWS Organizations Service Control Policies (SCPs) for additional controls
Access Monitoring
Enable AWS CloudTrail to log all role assumptions
Monitor and alert on unusual patterns of role usage
Regularly review and audit role permissions
Here's a complete setup using AWS CLI:
Common issues and solutions:
Access Denied Errors
Verify trust policy correctly lists trusted account
Ensure permission policies grant necessary actions
Check if user/role in trusted account has sts:AssumeRole permission
Check for conflicting permission boundaries or SCPs
Unable to Assume Role
Confirm IAM user/role has explicit permission to assume the role
Verify external ID if required
Check for correct role ARN usage
Ensure trust policy and assume role permission policy ARNs match exactly
Unexpected Access Levels
Review effective permissions using IAM Access Analyzer
Check for inherited permissions from group memberships
Evaluate any resource-based policies
Cross-account IAM roles are a powerful feature that enables secure resource sharing across AWS accounts while maintaining strong security controls and audit capabilities. The setup requires configuration in both accounts: the role and its policies in the trusting account, and the necessary assume role permissions in the trusted account. By following the best practices and implementation guidelines outlined above, you can effectively use cross-account roles in your AWS environment.