# iam:PassRole: policy example and why it matters

IAM policy examples · Updated 17 November 2026

**Short answer:** iam:PassRole is checked when you hand a role to a service, for example creating a Lambda function or launching an EC2 instance with an instance profile. Allow it only on the specific role ARNs, with iam:PassedToService naming the service, never on Resource "*".

## The policy

```
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "PassOrdersRoleToLambdaOnly",
      "Effect": "Allow",
      "Action": "iam:PassRole",
      "Resource": "arn:aws:iam::123456789012:role/orders-api-lambda",
      "Condition": {
        "StringEquals": {
          "iam:PassedToService": "lambda.amazonaws.com"
        }
      }
    },
    {
      "Sid": "DeployOrdersFunction",
      "Effect": "Allow",
      "Action": [
        "lambda:CreateFunction",
        "lambda:UpdateFunctionCode",
        "lambda:UpdateFunctionConfiguration",
        "lambda:GetFunction"
      ],
      "Resource": "arn:aws:lambda:eu-west-2:123456789012:function:orders-api"
    }
  ]
}
```

## What PassRole actually is

There is no PassRole API. It is a permission IAM checks when another API accepts a role ARN: `lambda:CreateFunction --role`, `ec2:RunInstances` with an instance profile, `ecs:RegisterTaskDefinition` with task roles, CloudFormation with a service role, and many more.

The point is to stop privilege escalation. If you could create a function with *any* role, you could pick an admin role, have the function do whatever you like, and bypass your own restrictions. So you need permission both to create the function and to pass that particular role.

- **PassOrdersRoleToLambdaOnly**: only this role, and only to Lambda. The same role can't be passed to EC2 or Glue.
- **DeployOrdersFunction**: the deploy actions on the one function.

## Service principals to use in the condition

| Passing a role to | `iam:PassedToService` |
|---|---|
| Lambda function | `lambda.amazonaws.com` |
| EC2 instance profile | `ec2.amazonaws.com` |
| ECS task role / execution role | `ecs-tasks.amazonaws.com` |
| CodeBuild project | `codebuild.amazonaws.com` |
| CloudFormation service role | `cloudformation.amazonaws.com` |
| Step Functions state machine | `states.amazonaws.com` |

```
aws iam put-user-policy --user-name deployer \
  --policy-name deploy-orders --policy-document file://passrole.json
```

## Variations

- **A family of roles**: use a path, `arn:aws:iam::123456789012:role/app/*`, and create workload roles under `/app/`. Combine with [permissions boundaries](https://cloudconsole.dev/iam/permissions-boundary) for delegated teams.
- **Only to a specific resource**: the `iam:AssociatedResourceArn` condition key can name the resource the role is passed to, for services that support it.
- **CI pipelines**: deploy roles used by [GitHub Actions](https://cloudconsole.dev/iam/github-actions-oidc) or CDK need PassRole on the roles they create or update; scope those the same way.

## Find who can pass powerful roles

Search your policies for `iam:PassRole` with a wildcard resource; each hit is a potential escalation path. The policy simulator can then confirm whether a given user may pass an admin role:

```
aws iam simulate-principal-policy \
  --policy-source-arn arn:aws:iam::123456789012:user/deployer \
  --action-names iam:PassRole \
  --resource-arns arn:aws:iam::123456789012:role/Admin
```

## Common mistakes

- **`iam:PassRole` on `"*"`**: anyone with it plus a compute service can act as any role in the account. Treat it like admin.
- **Misreading the error**: *not authorized to perform: iam:PassRole on resource* names the role you tried to pass, not your own.
- **Granting PassRole to the service role itself.** The role being passed doesn't need PassRole; the person or pipeline passing it does.
- **Wildcards in `iam:PassedToService`**: use exact service principals.

## Questions

### Why do I need iam:PassRole?

Any API that hands a role to a service checks it, so you can't give a service more power than you are allowed to delegate.

### Is iam:PassRole on * dangerous?

Yes. Combined with the ability to create compute (Lambda, EC2, ECS), it lets a user run code as any role in the account, including admin roles.

## When this happens away from your desk

PassRole errors usually stop a deploy halfway. The CloudTrail event for the failed call, which you can read from a phone, names both the caller and the role it tried to pass.

[About the CloudConsole app](https://cloudconsole.dev/aws-console-app) · [Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710)

## Sources

- [Grant a user permissions to pass a role to an AWS service](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_passrole.html)
- [AWS global condition context keys](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html)

## Related

- [Lambda execution role: trust policy and basic permissions](https://cloudconsole.dev/iam/lambda-execution-role)
- [IAM permissions boundary: let developers create roles safely](https://cloudconsole.dev/iam/permissions-boundary)
- [ECS task role vs task execution role](https://cloudconsole.dev/iam/ecs-task-role-vs-execution-role)
- [IAM role for an EC2 instance to access S3](https://cloudconsole.dev/iam/ec2-instance-role-s3)
- [AccessDeniedException: User is not authorized to perform this action because no identity-based policy allows it](https://cloudconsole.dev/errors/accessdenied-no-identity-based-policy-allows)
- [GitHub Actions OIDC: IAM role trust policy](https://cloudconsole.dev/iam/github-actions-oidc)

---

Source: https://cloudconsole.dev/iam/iam-passrole

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
