Sub topic 2
The trusted and trusting account model
This chapter assumes you know what IAM users, roles, and JSON policy documents are, and that you have used the AWS CLI. It covers the two-sided model behind every cross-account role. Later chapters write the policies and make the calls.
Two accounts, two names
Cross-account access with a role involves two accounts.
- The trusting account owns the role and the resources the role can reach. It trusts another account to use the role.
- The trusted account holds the users or roles that want access. Its principals are the ones the trusting account trusts.
The names describe the direction of trust, not the direction of access. In the examples used in this tutorial, account 222222222222 is the trusting account. It owns the role ReadOnlyAuditor. Account 111111111111 is the trusted account, and its users or roles call sts:AssumeRole to use that role.
Why both accounts must agree
An administrator in one account cannot grant access to resources in another account alone. For cross-account role access, two separate policies must both allow the request:
- The trust policy on the role, in the trusting account. It says which principals may assume the role.
- An identity policy on the caller, in the trusted account. It says that this caller may call
sts:AssumeRoleon that role.
A third policy, the role's permissions policy, decides what the session can do after the role is assumed. It is covered in the next chapter.
If either of the first two is missing, the call fails with AccessDenied. This is deliberate. The trusting account cannot force access onto a caller, and the trusted account cannot reach into another account on its own.
What each side contributes
| Side | Account | Policy | Question it answers |
|---|---|---|---|
| Trusting | 222222222222 | Trust policy | Who may assume this role? |
| Trusting | 222222222222 | Permissions policy | What can the role do once assumed? |
| Trusted | 111111111111 | Identity policy | Which roles may this caller assume? |
A note on the trust principal
A trust policy names a principal. When it names arn:aws:iam::111111111111:root, it does not mean the root user. It means the account as a whole. The trusting account hands the decision to the trusted account: any principal in 111111111111 that has its own sts:AssumeRole permission can assume the role.
That is why the identity policy matters. The trust policy opens the door to the account, and the identity policy in the trusted account chooses who walks through. You can also name a specific user or role ARN in the trust policy to narrow it from the trusting side.
Who is responsible for what
The split gives each account a clear job.
- The trusting account controls the scope of access. It decides what the role can do and which accounts or principals may use it.
- The trusted account controls which of its own principals may use that access.
Keeping this split in mind makes errors easier to read. If a call fails, ask which side is missing. A missing trust entry is fixed in the trusting account. A missing sts:AssumeRole permission is fixed in the trusted account.
Exercise
A developer in account 111111111111 gets AccessDenied when calling sts:AssumeRole on a role in account 222222222222. The trust policy on the role names arn:aws:iam::111111111111:root. Which account's policy should you check next, and what are you looking for?
Show answer
Check the identity policy in account 111111111111 (the trusted account). The trust policy already opens the role to that account, so the likely gap is that the developer's user or role lacks an Allow for sts:AssumeRole on the role's ARN.