# IAM policy example: let Lambda assume an execution role, with a least privilege rewrite

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

Lets the Lambda service assume an execution role so a function receives temporary credentials. The original also trusts the edge variant of Lambda, which only Lambda@Edge functions use. The rewrite keeps lambda.amazonaws.com. Resource names and account 111122223333 are placeholders used in AWS documentation.

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

## What it allows

- Allows the Lambda service and the Lambda@Edge service to assume the role.

- Allows Service lambda.amazonaws.com, Service edgelambda.amazonaws.com to sts:AssumeRole.

Checks:
- low: Trusts lambda.amazonaws.com, edgelambda.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)

The role trusts a service the function never uses, so a Lambda@Edge function could also take this role.

## Least privilege rewrite

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

The rewrite drops edgelambda.amazonaws.com. Only the Lambda service can assume the role.

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

Checks:
- low: Trusts lambda.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)

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

## Related pages

- [IAM policy example: cross-account role with external ID](/examples/trust-policy-cross-account-external-id/)
- [IAM policy example: trust GitHub Actions through OIDC](/examples/trust-policy-github-actions-oidc/)
- [IAM policy example: trust one EKS service account](/examples/trust-policy-eks-service-account-irsa/)
- [All of them](/examples/)

## Sources

- 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-lambda-execution-role/

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