# IAM policy example: let a user pass one role to Lambda, with a least privilege rewrite

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

Allows a principal to pass one named role to the Lambda service when creating or updating a function. The iam:PassedToService condition key stops the same role from being passed to EC2 or another service. The original allows iam:PassRole on every role.

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "PassAnyRole",
      "Effect": "Allow",
      "Action": "iam:PassRole",
      "Resource": "*"
    }
  ]
}
```

## What it allows

- Allows passing any role in the account to any service.

- Allows 1 action (iam:PassRole) on every resource.

Checks:
- medium: Allows 1 write or permissions-management action on every resource ("Resource": "*"). (https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html)
- high: Allows iam:PassRole on every resource: the principal can pass any role, including more privileged ones, to a service. (https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_passrole.html)

Passing an administrator role to a service the caller controls can raise the caller's privileges to administrator.

## Least privilege rewrite

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "PassOneRole",
      "Effect": "Allow",
      "Action": "iam:PassRole",
      "Resource": "arn:aws:iam::111122223333:role/lambda-orders-role",
      "Condition": {
        "StringEquals": {
          "iam:PassedToService": "lambda.amazonaws.com"
        }
      }
    }
  ]
}
```

The rewrite names one role and one receiving service. No other role can be passed, and this role cannot be passed to another service.

- Allows 1 action (iam:PassRole) on arn:aws:iam::111122223333:role/lambda-orders-role when iam:PassedToService StringEquals lambda.amazonaws.com.

Checks:
- No flags.

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

## Related pages

- [IAM policy example: let a team create roles under one path](/examples/iam-delegate-role-management-by-path/)
- [IAM policy example: read IAM configuration for an audit](/examples/iam-read-only-audit/)
- [IAM policy example: use one KMS key to encrypt and decrypt](/examples/kms-encrypt-decrypt-one-key/)
- [All of them](/examples/)

## Sources

- IAM User Guide: grant a user permissions to pass a role: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_passrole.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/iam-pass-one-role-to-lambda/

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