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.
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
Allow 1 action (iam:PassRole) on every resource.
Action or pattern Actions Access levels iam:PassRole1 Write 1
Checks
- Medium Allows 1 write or permissions-management action on every resource ("Resource": "*"). AWS documentation for this check
- High Allows iam:PassRole on every resource: the principal can pass any role, including more privileged ones, to a service. AWS documentation for this check
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
Allow 1 action (iam:PassRole) on arn:aws:iam::111122223333:role/lambda-orders-role when iam:PassedToService StringEquals lambda.amazonaws.com.
Action or pattern Actions Access levels iam:PassRole1 Write 1
Checks
No flags from the six checks.
Related pages
Sources
- IAM User Guide: grant a user permissions to pass a role, read 16 Nov 2026
- AWS Service Authorization Reference, programmatic access (fetched 16 Nov 2026), read 16 Nov 2026
Last reviewed 16 Nov 2026.