# IAM policy example: let an SNS topic send to an SQS queue, with a least privilege rewrite

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

A queue policy that lets one SNS topic send messages to the queue orders-queue. The original uses Principal * and relies on aws:SourceArn alone. The rewrite names the SNS service as principal and adds the account condition. Resource names and account 111122223333 are placeholders used in AWS documentation.

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "TopicToQueue",
      "Effect": "Allow",
      "Principal": "*",
      "Action": "sqs:SendMessage",
      "Resource": "arn:aws:sqs:us-east-1:111122223333:orders-queue",
      "Condition": {
        "ArnEquals": {
          "aws:SourceArn": "arn:aws:sns:us-east-1:111122223333:orders-topic"
        }
      }
    }
  ]
}
```

## What it allows

- Allows any principal to send messages to the queue when the request is made on behalf of the topic orders-topic.

- Allows 1 action (sqs:SendMessage) on arn:aws:sqs:us-east-1:111122223333:orders-queue for AWS * when aws:SourceArn ArnEquals arn:aws:sns:us-east-1:111122223333:orders-topic.

Checks:
- No flags.

Principal * leaves the condition as the only guard, and a mistake in the condition would open the queue to anyone.

## Least privilege rewrite

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "TopicToQueue",
      "Effect": "Allow",
      "Principal": {
        "Service": "sns.amazonaws.com"
      },
      "Action": "sqs:SendMessage",
      "Resource": "arn:aws:sqs:us-east-1:111122223333:orders-queue",
      "Condition": {
        "ArnEquals": {
          "aws:SourceArn": "arn:aws:sns:us-east-1:111122223333:orders-topic"
        },
        "StringEquals": {
          "aws:SourceAccount": "111122223333"
        }
      }
    }
  ]
}
```

The rewrite names sns.amazonaws.com as the principal and adds aws:SourceAccount. Only the one topic in the account can send.

- Allows 1 action (sqs:SendMessage) on arn:aws:sqs:us-east-1:111122223333:orders-queue for Service sns.amazonaws.com when aws:SourceArn ArnEquals arn:aws:sns:us-east-1:111122223333:orders-topic and aws:SourceAccount StringEquals 111122223333.

Checks:
- No flags.

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

## Related pages

- [IAM policy example: let S3 invoke a Lambda function](/examples/lambda-resource-policy-allow-s3-invoke/)
- [IAM policy example: SNS topic policy for alarms](/examples/sns-topic-policy-allow-cloudwatch-alarms/)
- [IAM policy example: ECR policy for cross-account pull](/examples/ecr-repository-policy-cross-account-pull/)
- [All of them](/examples/)

## Sources

- Amazon SQS Developer Guide: basic policy examples: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-basic-examples-of-sqs-policies.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/sqs-queue-policy-allow-sns-topic/

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