Skip to content
IAM Policy Generator

IAM policy example: SNS topic policy for alarms, with a least privilege rewrite

A topic policy that lets CloudWatch alarms in one account publish to the topic alerts-topic. The original names the CloudWatch service with no condition. The rewrite adds aws:SourceArn for alarms in one Region and aws:SourceAccount. Resource names and account 111122223333 are placeholders used in AWS documentation.

Open the workbench ยท All examples

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AlarmsPublish",
      "Effect": "Allow",
      "Principal": {
        "Service": "cloudwatch.amazonaws.com"
      },
      "Action": "sns:Publish",
      "Resource": "arn:aws:sns:us-east-1:111122223333:alerts-topic"
    }
  ]
}

What it allows

  • Allows the CloudWatch service to publish to the topic.

What it allows

  1. Allow 1 action (sns:Publish) on arn:aws:sns:us-east-1:111122223333:alerts-topic for Service cloudwatch.amazonaws.com.

    Action or patternActionsAccess levels
    sns:Publish1Write 1

Checks

No flags from the six checks.

The service principal has no source condition, so an alarm in any account that names this topic could publish to it.

Least privilege rewrite

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AlarmsPublish",
      "Effect": "Allow",
      "Principal": {
        "Service": "cloudwatch.amazonaws.com"
      },
      "Action": "sns:Publish",
      "Resource": "arn:aws:sns:us-east-1:111122223333:alerts-topic",
      "Condition": {
        "ArnLike": {
          "aws:SourceArn": "arn:aws:cloudwatch:us-east-1:111122223333:alarm:*"
        },
        "StringEquals": {
          "aws:SourceAccount": "111122223333"
        }
      }
    }
  ]
}

The rewrite limits publishing to alarms in us-east-1 and account 111122223333. Alarms from other accounts are refused.

What it allows

  1. Allow 1 action (sns:Publish) on arn:aws:sns:us-east-1:111122223333:alerts-topic for Service cloudwatch.amazonaws.com when aws:SourceArn ArnLike arn:aws:cloudwatch:us-east-1:111122223333:alarm:* and aws:SourceAccount StringEquals 111122223333.

    Action or patternActionsAccess levels
    sns:Publish1Write 1

Checks

No flags from the six checks.

Sources

  1. Amazon SNS Developer Guide: access policy use cases, read 16 Nov 2026
  2. IAM User Guide: the confused deputy problem, read 16 Nov 2026
  3. AWS Service Authorization Reference, programmatic access (fetched 16 Nov 2026), read 16 Nov 2026

Last reviewed 16 Nov 2026.