Skip to content
IAM Policy Generator

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

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.

Open the workbench ยท All examples

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

What it allows

  1. Allow Service lambda.amazonaws.com, Service edgelambda.amazonaws.com to sts:AssumeRole.

    Action or patternActionsAccess levels
    sts:AssumeRole1Write 1

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. AWS documentation for this check

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

Least privilege rewrite

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

What it allows

  1. Allow Service lambda.amazonaws.com to sts:AssumeRole.

    Action or patternActionsAccess levels
    sts:AssumeRole1Write 1

Checks

  • Low Trusts lambda.amazonaws.com with no aws:SourceArn or aws:SourceAccount condition, which AWS recommends against the confused deputy problem. AWS documentation for this check

Sources

  1. IAM User Guide: create a role for an AWS service, read 16 Nov 2026
  2. AWS Service Authorization Reference, programmatic access (fetched 16 Nov 2026), read 16 Nov 2026

Last reviewed 16 Nov 2026.