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

Facts read 16 Nov 2026. Page reviewed 16 Nov 2026.

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.

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

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

Checks:
- No flags.

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

## Least privilege rewrite

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

- Allows 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.

Checks:
- No flags.

- [Paste it into the workbench](/)
- [Every SNS action and its access level](/actions/sns/)

## Related pages

- [IAM policy example: ECR policy for cross-account pull](/examples/ecr-repository-policy-cross-account-pull/)
- [IAM policy example: read one S3 bucket](/examples/s3-read-one-bucket/)
- [IAM policy example: read and write one S3 bucket](/examples/s3-read-write-one-bucket/)
- [All of them](/examples/)

## Sources

- Amazon SNS Developer Guide: access policy use cases: https://docs.aws.amazon.com/sns/latest/dg/sns-access-policy-use-cases.html (read 16 Nov 2026)
- IAM User Guide: the confused deputy problem: https://docs.aws.amazon.com/IAM/latest/UserGuide/confused-deputy.html (read 16 Nov 2026)
- AWS Service Authorization Reference, programmatic access (fetched 16 Nov 2026): https://docs.aws.amazon.com/service-authorization/latest/reference/service-reference.html (read 16 Nov 2026)

Last reviewed 16 Nov 2026. Canonical: https://iampolicygenerator.com/examples/sns-topic-policy-allow-cloudwatch-alarms/

This site is not affiliated with Amazon Web Services. AWS service and product names are used only to describe AWS services.
