Cross-Account Roles and Resource Policies
Grant one account scoped access to resources in another.
Cross-Account Roles and Resource Policies is a free AWS Security Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AWS Security Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Why Cross-Account Access
Real architectures span many accounts: a production account, a logging account, a shared-services account. Workloads and people often need to reach resources across these boundaries.
The secure way is never to copy credentials between accounts. Instead, you grant scoped access using cross-account roles or resource-based policies.
The Cross-Account Role Pattern
The most common pattern is a role in the target account that a principal in the source account assumes.
- The role's trust policy names the source account or principal.
- The source principal calls AssumeRole and receives temporary credentials.
- It then acts in the target account within the role's permissions.
Two Policies Must Agree
Cross-account role assumption requires both sides to permit it:
- The target role's trust policy allows the source principal.
- The source principal's identity policy allows sts:AssumeRole on that role.
If either is missing, the assumption fails. This double check is a frequent exam point.
Resource-Based Policies
Some services support resource-based policies attached directly to the resource, such as an S3 bucket policy, KMS key policy, or SQS queue policy.
These can grant access to a principal in another account without that principal assuming a role. The external account uses its own identity and the resource policy authorizes it.
{
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::444455556666:root" },
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::shared-logs-bucket/*"
}Role Chaining vs Resource Policies
Choose the mechanism by the service:
- For services with no resource policy (EC2, most APIs), use a cross-account role.
- For S3, KMS, SNS, SQS, Lambda, and others, a resource policy can grant direct cross-account access.
Resource policies avoid an extra AssumeRole hop.
The External ID Safeguard
When granting a third party (like a SaaS vendor) cross-account access, add an external ID condition to the trust policy.
The vendor must pass a unique secret value when assuming the role. This blocks the confused deputy problem, where an attacker tricks the vendor into accessing the wrong customer's account.
Least Privilege Across Accounts
Cross-account roles should grant the minimum needed, scoped to specific resources and actions.
A common mistake is a broad trust to an entire external account combined with administrator permissions. Tighten the trust to a specific role or user, and the permissions to the exact task.
Centralized Service Accounts
A frequent design centralizes a function in one account that others reach via roles, for example a security account assuming read-only roles into every workload account.
Each workload account hosts an identically named role trusting the security account, so tooling can scan all accounts uniformly.
Sharing with RAM
AWS Resource Access Manager (RAM) shares specific resources, like subnets or Transit Gateways, across accounts in an organization.
RAM is for sharing the resource itself rather than granting API permissions to act on it. It complements roles and resource policies for network and infrastructure sharing.
Auditing Cross-Account Paths
Cross-account access widens your trust surface, so audit it regularly.
- CloudTrail records every AssumeRole and cross-account API call.
- IAM Access Analyzer flags resource policies that grant access outside your account.
Review these to catch unintended sharing early.
Putting It Together
To connect accounts securely: prefer roles for compute and APIs, resource policies for storage and messaging services, and always apply least privilege with an external ID for third parties.
Never share long-term keys between accounts.
Quick Check
Reason about cross-account access.
Recap
You learned how to connect accounts safely.
- Cross-account roles need both a trust policy and a source identity policy.
- Resource-based policies grant direct access for services like S3 and KMS.
- Use an external ID for third parties and audit with Access Analyzer and CloudTrail.
Frequently asked questions
Is the “Cross-Account Roles and Resource Policies” lesson free?
Yes — the full text of “Cross-Account Roles and Resource Policies” is free to read here on the web, and the AWS Security Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AWS Security Academy course, upgrade to CoddyKit PRO.
What will I learn in “Cross-Account Roles and Resource Policies”?
Grant one account scoped access to resources in another. You practise AWS Security Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start AWS Security Academy?
No prior experience is required. AWS Security Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Cross-Account Roles and Resource Policies” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this AWS Security Academy lesson?
Yes. Every AWS Security Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Single Sign-On with IAM Identity Center
- SAML, OIDC, and Web Identity Federation
- Cross-Account Roles and Resource Policies
- Auditing Sharing with IAM Access Analyzer