# IAM policy example: trust a service for one resource only, with a least privilege rewrite

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

Lets the EventBridge Scheduler service assume a role only for schedules in one schedule group and one account, using aws:SourceArn and aws:SourceAccount. The conditions prevent another customer's schedule from using the role. The original has no conditions. Resource names and account 111122223333 are placeholders used in AWS documentation.

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Scheduler",
      "Effect": "Allow",
      "Principal": {
        "Service": "scheduler.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
    }
  ]
}
```

## What it allows

- Allows the Scheduler service to assume the role for any schedule.

- Allows Service scheduler.amazonaws.com to sts:AssumeRole.

Checks:
- low: Trusts scheduler.amazonaws.com with no aws:SourceArn or aws:SourceAccount condition, which AWS recommends against the confused deputy problem. (https://docs.aws.amazon.com/IAM/latest/UserGuide/confused-deputy.html)

Without a source condition, the confused deputy problem applies: a schedule created elsewhere that names this role could use it.

## Least privilege rewrite

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "SchedulerGroup",
      "Effect": "Allow",
      "Principal": {
        "Service": "scheduler.amazonaws.com"
      },
      "Action": "sts:AssumeRole",
      "Condition": {
        "StringEquals": {
          "aws:SourceAccount": "111122223333"
        },
        "ArnLike": {
          "aws:SourceArn": "arn:aws:scheduler:us-east-1:111122223333:schedule-group/orders"
        }
      }
    }
  ]
}
```

The rewrite requires the request to come from account 111122223333 and from the orders schedule group. Other schedules cannot use the role.

- Allows Service scheduler.amazonaws.com to sts:AssumeRole when aws:SourceAccount StringEquals 111122223333 and aws:SourceArn ArnLike arn:aws:scheduler:us-east-1:111122223333:schedule-group/orders.

Checks:
- No flags.

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

## Related pages

- [IAM policy example: trust a SAML identity provider](/examples/trust-policy-saml-federation/)
- [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/)
- [All of them](/examples/)

## Sources

- IAM User Guide: the confused deputy problem: https://docs.aws.amazon.com/IAM/latest/UserGuide/confused-deputy.html (read 16 Nov 2026)
- IAM User Guide: create a role for an AWS service: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.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-service-with-source-arn/

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