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.
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
Allow Service lambda.amazonaws.com, Service edgelambda.amazonaws.com to sts:AssumeRole.
Action or pattern Actions Access levels sts:AssumeRole1 Write 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
Allow Service lambda.amazonaws.com to sts:AssumeRole.
Action or pattern Actions Access levels sts:AssumeRole1 Write 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
Related pages
Sources
- IAM User Guide: create a role for an AWS service, read 16 Nov 2026
- AWS Service Authorization Reference, programmatic access (fetched 16 Nov 2026), read 16 Nov 2026
Last reviewed 16 Nov 2026.