# IAM policy example: trust a SAML identity provider, with a least privilege rewrite

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

Lets users signed in through a SAML 2.0 identity provider assume a role by calling AssumeRoleWithSAML, and requires the SAML audience to be the AWS sign-in URL. The original has no audience condition. The rewrite adds the condition. Resource names and account 111122223333 are placeholders used in AWS documentation.

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Saml",
      "Effect": "Allow",
      "Principal": {
        "Federated": "arn:aws:iam::111122223333:saml-provider/ExampleProvider"
      },
      "Action": "sts:AssumeRoleWithSAML"
    }
  ]
}
```

## What it allows

- Allows a user whose SAML assertion comes from ExampleProvider to assume the role.

- Allows Federated arn:aws:iam::111122223333:saml-provider/ExampleProvider to sts:AssumeRoleWithSAML.

Checks:
- No flags.

Without an audience condition, an assertion issued for another relying party could be accepted.

## Least privilege rewrite

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "SamlAudience",
      "Effect": "Allow",
      "Principal": {
        "Federated": "arn:aws:iam::111122223333:saml-provider/ExampleProvider"
      },
      "Action": "sts:AssumeRoleWithSAML",
      "Condition": {
        "StringEquals": {
          "SAML:aud": "https://signin.aws.amazon.com/saml"
        }
      }
    }
  ]
}
```

The rewrite adds the SAML:aud condition so only assertions meant for the AWS sign-in endpoint are accepted.

- Allows Federated arn:aws:iam::111122223333:saml-provider/ExampleProvider to sts:AssumeRoleWithSAML when SAML:aud StringEquals https://signin.aws.amazon.com/saml.

Checks:
- No flags.

- [Paste it into the workbench](/)
- [Every STS action and its access level](/actions/sts/)

## Related pages

- [IAM policy example: trust Identity Center roles](/examples/trust-policy-identity-center-permission-set-role/)
- [IAM policy example: S3 bucket policy for TLS and org](/examples/s3-bucket-policy-enforce-tls-and-organization/)
- [IAM policy example: write a KMS key policy](/examples/kms-key-policy-account-admin-and-key-user/)
- [All of them](/examples/)

## Sources

- IAM User Guide: create a role for SAML 2.0 federation: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_saml.html (read 16 Nov 2026)
- AWS Service Authorization Reference, programmatic access (fetched 16 Nov 2026): https://docs.aws.amazon.com/service-authorization/latest/reference/service-reference.html (read 16 Nov 2026)

Last reviewed 16 Nov 2026. Canonical: https://iampolicygenerator.com/examples/trust-policy-saml-federation/

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