IAM policy example: let a Lambda function write logs, with a least privilege rewrite
Facts read 16 Nov 2026. Page reviewed 16 Nov 2026.
Gives a Lambda execution role the CloudWatch Logs actions needed to create its log group and stream and write events. The original allows logs:* on every log group. The rewrite names the function's own log group and three actions. Resource names and account 111122223333 are placeholders used in AWS documentation.
Open the workbench ยท All examples
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Logs",
"Effect": "Allow",
"Action": "logs:*",
"Resource": "*"
}
]
}
What it allows
- Allows every CloudWatch Logs action on every log group and stream.
What it allows
Allow 133 actions (logs:*) on every resource.
Action or pattern Actions Access levels logs:*133 List 33, Read 26, Write 68, Permissions management 2, Tagging 4
Checks
- High Allows 70 write or permissions-management actions (2 permissions management) on every resource ("Resource": "*"). AWS documentation for this check
The action logs:* covers 133 actions, including deleting log groups and reading other applications' logs.
Least privilege rewrite
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "CreateGroup",
"Effect": "Allow",
"Action": "logs:CreateLogGroup",
"Resource": "arn:aws:logs:us-east-1:111122223333:*"
},
{
"Sid": "WriteLogs",
"Effect": "Allow",
"Action": [
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "arn:aws:logs:us-east-1:111122223333:log-group:/aws/lambda/my-function:*"
}
]
}
The rewrite lets the role create a group, then create streams and write events only in the log group named for the function.
What it allows
Allow 1 action (logs:CreateLogGroup) on arn:aws:logs:us-east-1:111122223333:*.
Action or pattern Actions Access levels logs:CreateLogGroup1 Write 1 Allow 2 actions (logs:CreateLogStream, logs:PutLogEvents) on arn:aws:logs:us-east-1:111122223333:log-group:/aws/lambda/my-function:*.
Action or pattern Actions Access levels logs:CreateLogStream1 Write 1 logs:PutLogEvents1 Write 1
Checks
No flags from the six checks.
Related pages
Sources
- AWS Lambda Developer Guide: permissions, read 16 Nov 2026
- Amazon CloudWatch Logs User Guide: managing access, read 16 Nov 2026
- AWS Service Authorization Reference, programmatic access (fetched 16 Nov 2026), read 16 Nov 2026
Last reviewed 16 Nov 2026.