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.
Open the workbench ยท All examples
{
"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.
What it allows
Allow 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.
Action or pattern Actions Access levels sqs:SendMessage1 Write 1
Checks
No flags from the six checks.
Principal * leaves the condition as the only guard, and a mistake in the condition would open the queue to anyone.
Least privilege rewrite
{
"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.
What it allows
Allow 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.
Action or pattern Actions Access levels sqs:SendMessage1 Write 1
Checks
No flags from the six checks.
Related pages
Sources
- Amazon SQS Developer Guide: basic policy examples, read 16 Nov 2026
- IAM User Guide: the confused deputy problem, read 16 Nov 2026
- AWS Service Authorization Reference, programmatic access (fetched 16 Nov 2026), read 16 Nov 2026
Last reviewed 16 Nov 2026.