Sub topic 8
Same-account and cross-account requests
This chapter assumes you can read IAM policy JSON, know the difference between an identity-based policy and a resource-based policy, and know the core rule from earlier chapters: everything is denied by default, an explicit deny always wins, and otherwise at least one allow is needed. Here you will see how the account that owns the resource changes which policies must allow a request.
Why the account boundary matters
An AWS account is a trust boundary. A principal (the user or role making the request) either lives in the same account as the resource or in a different one. That single fact changes how identity-based and resource-based policies combine.
- Same account: an allow in either the identity-based policy or the resource-based policy is enough, as long as nothing denies the request.
- Cross-account: both sides must allow. The resource's account must trust the principal, and the principal's own account must let the principal make the call.
The reason is simple. The owner of a resource can decide who may use it. But the owner of a principal also decides what that principal may do. Neither account can grant permissions on behalf of the other.
Same-account evaluation
Suppose the role ReportWriter and the bucket example-reports-bucket both belong to account 111122223333. The role has this identity-based policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ReadWriteReports",
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3:::example-reports-bucket/*"
}
]
}If the bucket has no bucket policy, the request still succeeds. The identity policy alone provides the allow. The same is true in reverse: if the bucket policy names the role as a principal and allows s3:GetObject, the role can read objects even if its identity policy says nothing about S3.
Two things can still stop a same-account request:
- An explicit deny in any applicable policy.
- A limit that removes the allow, such as a permission boundary, a session policy, or a service control policy (SCP). These are covered in later chapters.
There is one nuance for IAM users and roles. If a resource-based policy names a specific IAM user or role ARN as the principal, that allow works without the principal's identity policy, even when permission limits such as boundaries exist on that principal. If the resource policy names only the account root or a broad principal, the identity side still has to allow the action. Treat this as a detail to verify for each service, because it depends on how the principal is named and on the kind of credentials in use. For example, resource-policy allows for assumed-role sessions behave differently from allows for role ARNs.
Cross-account evaluation
Now put the bucket in account 111122223333 and the role ReportReader in account 222233334444. The bucket policy in the bucket's account says:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowReportReaderRoleFromOtherAccount",
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::222233334444:role/ReportReader" },
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::example-reports-bucket/*"
}
]
}This is only half of the permission. It says the bucket owner trusts the role. The role's own account must also allow the call, so ReportReader needs an identity-based policy in account 222233334444 that allows s3:GetObject on the same resource. If either half is missing, the request is denied.
The two accounts side by side
| Situation | Identity policy allows | Resource policy allows | Result |
|---|---|---|---|
| Same account | Yes | No | Allowed |
| Same account | No | Yes (names the principal) | Allowed |
| Same account | No | No | Implicit deny |
| Cross-account | Yes | No | Denied |
| Cross-account | No | Yes | Denied |
| Cross-account | Yes | Yes | Allowed |
| Any | Any | Any, with an explicit deny | Denied |
What the resource policy names
The Principal element decides who the resource owner is trusting. Its value affects how much work the other account has to do.
- A specific role or user ARN, as in the example above. Only that principal is trusted. If the role is deleted and recreated with the same name, the new role matches the name, but the stored principal ID differs. AWS handles this by converting the ARN to a principal ID when the policy is saved, so a recreated role does not silently inherit access. After a deletion, the policy may display the raw ID instead of the ARN.
- An account root, such as
arn:aws:iam::222233334444:root. This does not mean only the root user. It delegates to the entire account: the other account's administrators decide, through identity policies, which of their principals may use the resource. - A wildcard (
"Principal": "*"). This trusts everyone, including anonymous callers, unless a condition narrows it. Use it only with conditions such asaws:PrincipalOrgID, and review it carefully.
Delegating to the account root is common when a resource owner wants to trust a whole partner account but let that partner manage who inside it gets access. The cost is that the resource owner no longer controls which principals in that account can reach the resource.
Roles and the trust policy
Cross-account access has a second route that avoids resource policies: the principal assumes a role in the resource's account. In that model the request is made as a principal of the resource's account, so it is evaluated as a same-account request.
Assuming a role itself is a cross-account request. Two policies are involved:
- The role's trust policy (a resource-based policy attached to the role) must name the caller or the caller's account.
- The caller's identity policy must allow
sts:AssumeRoleon the role's ARN.
Once assumed, the caller uses the role's temporary credentials. The caller's original permissions no longer apply to requests made with those credentials. Only the role's permissions apply, plus any session policy passed at assumption time.
This trade-off matters when choosing between the two approaches:
| Approach | Strength | Cost |
|---|---|---|
| Resource policy naming the foreign principal | Caller keeps their own identity, which CloudTrail records as such, and no credential switch is needed | Not every service supports resource policies, and each resource needs its own policy |
| Assume a role in the resource's account | Works for any service the role can reach, with one trust setup | Caller works with a different identity and gives up their original permissions while using it |
Common errors
- Only one side configured. The most frequent cross-account failure. A bucket policy allows the foreign role, but the role's identity policy does not mention S3. The result is
AccessDeniedwith no hint about which side is missing. - Wrong resource ARN in the bucket policy. Object actions such as
s3:GetObjectneed the/*form of the ARN. Bucket actions such ass3:ListBucketneed the bucket ARN without/*. - Assuming the root principal means one user. It means the whole account.
- Expecting the identity policy to override a deny in the other account. An explicit deny on either side blocks the request. For example, the bucket's TLS-only deny applies to the foreign role as well:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyInsecureTransport",
"Effect": "Deny",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::example-reports-bucket",
"arn:aws:s3:::example-reports-bucket/*"
],
"Condition": { "Bool": { "aws:SecureTransport": "false" } }
}
]
}- Forgetting other account-level limits. In the principal's account, an SCP or permission boundary can remove the identity-side allow. In the resource's account, an SCP does not restrict the foreign principal, because SCPs affect principals in the accounts they apply to, not outside callers. Check the SCPs of the principal's account.
- Assuming all services behave like S3. Some services do not support resource-based policies at all. For those, cross-account access requires assuming a role.
Checking a cross-account path
The IAM policy simulator can test the principal side. It evaluates the policies attached to the role in its own account. You can also pass a resource policy to the simulation, so you can test the combined effect.
aws iam simulate-principal-policy \
--policy-source-arn arn:aws:iam::222233334444:role/ReportReader \
--action-names s3:GetObject \
--resource-arns arn:aws:s3:::example-reports-bucket/2026/summary.csvRun this in the principal's account. If the result is implicitDeny, the identity side is missing an allow. If it is allowed but real requests still fail, look at the bucket policy, a resource-side explicit deny, or an organization-level limit.
Summary of the rules
- Same account: one allow, from either policy type, is enough if nothing denies.
- Cross-account: both the resource policy and the principal's identity policy must allow.
- An explicit deny in any applicable policy ends the evaluation.
- Assuming a role in the resource's account turns the request into a same-account request, at the cost of switching identities.
Exercise
A role Analyst in account 444455556666 calls s3:GetObject on an object in a bucket owned by account 111122223333. The bucket policy allows Analyst to call s3:GetObject. The role's only identity policy allows s3:ListAllMyBuckets. Is the request allowed? What single change fixes it, and where?
Show answer
The request is denied. It is cross-account, so both sides must allow, and the principal's account has no allow for s3:GetObject. Add an identity-based policy to Analyst in account 444455556666 that allows s3:GetObject on arn:aws:s3:::example-reports-bucket/*, assuming no explicit deny or SCP blocks it.
Exercise
The same bucket policy and role exist in the same account (111122223333), and the role has no identity policy that mentions S3. The bucket policy names the role's ARN and allows s3:GetObject. Is the request allowed, and why does this differ from the cross-account case?
Show answer
It is allowed, provided nothing denies it and no permission limit on the role removes the allow. In the same account, an allow from either the identity policy or the resource policy is enough. Across accounts, each account must allow independently.