Skip to content
IAM Policy Generator

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

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.

Open the workbench ยท All examples

{
  "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.

What it allows

  1. Allow 1 action (iam:PassRole) on every resource.

    Action or patternActionsAccess levels
    iam:PassRole1Write 1

Checks

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

Least privilege rewrite

{
  "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.

What it allows

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

    Action or patternActionsAccess levels
    iam:PassRole1Write 1

Checks

No flags from the six checks.

Sources

  1. IAM User Guide: grant a user permissions to pass a role, read 16 Nov 2026
  2. AWS Service Authorization Reference, programmatic access (fetched 16 Nov 2026), read 16 Nov 2026

Last reviewed 16 Nov 2026.