# An AWS trust policy states who can assume a role, and conditions narrow it

Facts read 16 Nov 2026. Page reviewed 16 Nov 2026.

An AWS trust policy is the resource-based policy attached to an IAM role that names which principals may assume it. AWS documents conditions that narrow it: sts:ExternalId for third parties, aws:SourceArn and aws:SourceAccount for services, and token claims for OIDC providers. This page reads the anatomy from AWS documents on 16 Nov 2026.

## A trust policy is the only resource-based policy IAM supports

AWS says the IAM service supports one type of resource-based policy, called a role trust policy, which is attached to an IAM role. A role is both an identity and a resource. For that reason it needs two kinds of policy: a trust policy that says who may assume the role, and an identity-based policy that says what the role may do once assumed.

In the trust policy, the Principal element names who can assume the role. For cross-account access, you specify the 12-digit identifier of the trusted account. The Action is normally sts:AssumeRole, or sts:AssumeRoleWithWebIdentity or sts:AssumeRoleWithSAML for federated principals. An identity-based policy cannot contain a Principal element, because the principal is the identity it is attached to.

## Principals take seven shapes

| Principal type | Example value | Note from AWS |
| --- | --- | --- |
| AWS account and root user | "AWS": "123456789012" | Delegates authority to the account, which must still allow the call. |
| IAM role or role session | "AWS": "arn:aws:iam::123456789012:role/name" | Effective permissions are limited by any session policy or permissions boundary on the role. |
| IAM user | "AWS": "arn:aws:iam::123456789012:user/name" | User groups cannot be principals. |
| AWS service | "Service": "ec2.amazonaws.com" | Used for service roles. |
| OIDC federated | "Federated": "arn:aws:iam::123456789012:oidc-provider/..." | Matched to claims in the token. |
| SAML federated | "Federated": "arn:aws:iam::123456789012:saml-provider/..." | Used with AssumeRoleWithSAML. |
| All principals | "AWS": "*" | AWS says to limit who can assume the role by other means, such as a Condition element. |

## Three conditions cover most trust policy risks

For a third party, AWS says the external ID addresses the confused deputy problem. The third party gives you its AWS account ID and an external ID that only you and the third party know, you set it as a sts:ExternalId condition in the trust policy, and the third party must present it when assuming the role. AWS states that it does not treat the external ID as a secret: anyone with permission to view the role can see it. The external ID is from 2 to 1,224 characters long.

For AWS services, AWS recommends aws:SourceArn, aws:SourceAccount, aws:SourceOrgID or aws:SourceOrgPaths wherever a service principal is granted access, so the service acts for a resource, account or organization you expect. aws:SourceArn ties access to one resource such as a CloudTrail trail; aws:SourceAccount ties it to one account.

The workbench checks for a missing condition in both cases. It flags an Allow statement that trusts another account's ID or "*" with no guard, and a service principal with no source condition. A guard is any of sts:ExternalId, aws:SourceAccount, aws:SourceArn, aws:PrincipalOrgID, aws:PrincipalArn, aws:SourceOrgID or aws:PrincipalAccount.

## OIDC trust policies test claims in the identity provider's token

For OIDC, you create an IAM identity provider, then a role whose trust policy names the provider as a Federated principal. AWS says the token's aud claim is application specific and must match the audience value registered with the provider. The sub claim identifies the subject, and many providers put the repository, workflow or tenant in it. Conditions on these claim keys decide which tokens can assume the role.

AWS document history records recent changes for shared providers. On 6 Jun 2025 IAM began requiring explicit evaluation of specific claims for recognized shared OIDC providers, and on 1 Aug 2025 it added Amazon Cognito, Azure Sentinel, Pulumi Cloud and Vercel to the list. On 12 May 2026 IAM began accepting either the sub claim or the job_workflow_ref claim as the scoping control for the GitHub Actions OIDC provider. Trust policies for those providers should therefore test the claims AWS names.

## Trust policy length has its own quota

AWS sets a role trust policy length of 2,048 characters by default, with a maximum of 8,192 characters on request. White space is not counted. The page on [policy size limits](/iam-policy-size-limits/) lists the other IAM and Organizations limits.

Because a trust policy answers who may assume a role, and the permission policy answers what the role may do, review both. [The policy types page](/aws-iam-policy/) shows where a trust policy sits among the nine types.

## Related pages

- [IAM Condition Keys, Operators and IfExists](/condition-keys/)
- [IAM Policy Evaluation Logic in Plain Terms](/iam-policy-evaluation-logic/)
- [Inline vs Managed Policies in AWS IAM](/inline-vs-managed-policies/)
- [All of them](/guides/)

## Sources

- IAM JSON policy elements: Principal: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html (read 16 Nov 2026)
- External ID for third-party access: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-user_externalid.html (read 16 Nov 2026)
- The confused deputy problem: https://docs.aws.amazon.com/IAM/latest/UserGuide/confused-deputy.html (read 16 Nov 2026)
- Create an OpenID Connect identity provider in IAM: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_oidc.html (read 16 Nov 2026)
- Document history for IAM: https://docs.aws.amazon.com/IAM/latest/UserGuide/document-history.html (read 16 Nov 2026)
- IAM and AWS STS quotas: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html (read 16 Nov 2026)

Last reviewed 16 Nov 2026. Canonical: https://iampolicygenerator.com/aws-trust-policy/

This site is not affiliated with Amazon Web Services. AWS service and product names are used only to describe AWS services.
