Skip to content
IAM Policy Generator

IAM policy example: let a Lambda function write logs, with a least privilege rewrite

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

  1. Allow 133 actions (logs:*) on every resource.

    Action or patternActionsAccess levels
    logs:*133List 33, Read 26, Write 68, Permissions management 2, Tagging 4

Checks

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

  1. Allow 1 action (logs:CreateLogGroup) on arn:aws:logs:us-east-1:111122223333:*.

    Action or patternActionsAccess levels
    logs:CreateLogGroup1Write 1
  2. Allow 2 actions (logs:CreateLogStream, logs:PutLogEvents) on arn:aws:logs:us-east-1:111122223333:log-group:/aws/lambda/my-function:*.

    Action or patternActionsAccess levels
    logs:CreateLogStream1Write 1
    logs:PutLogEvents1Write 1

Checks

No flags from the six checks.

Sources

  1. AWS Lambda Developer Guide: permissions, read 16 Nov 2026
  2. Amazon CloudWatch Logs User Guide: managing access, read 16 Nov 2026
  3. AWS Service Authorization Reference, programmatic access (fetched 16 Nov 2026), read 16 Nov 2026

Last reviewed 16 Nov 2026.