1. IAM Producer Policy#
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowSendToOrderQueue",
"Effect": "Allow",
"Action": [
"sqs:SendMessage",
"sqs:GetQueueAttributes",
"sqs:GetQueueUrl"
],
"Resource": "arn:aws:sqs:ap-east-1:123456789012:prod-platform-checkout-order-payment-capture"
}
]
}2. IAM Consumer Policy#
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowConsumeOrderQueue",
"Effect": "Allow",
"Action": [
"sqs:ReceiveMessage",
"sqs:DeleteMessage",
"sqs:ChangeMessageVisibility",
"sqs:GetQueueAttributes",
"sqs:GetQueueUrl"
],
"Resource": "arn:aws:sqs:ap-east-1:123456789012:prod-platform-checkout-order-payment-capture"
}
]
}3. Queue Policy For SNS Fanout#
Use this when an SNS topic publishes to SQS. Restrict by aws:SourceArn.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowSnsTopicPublish",
"Effect": "Allow",
"Principal": {
"Service": "sns.amazonaws.com"
},
"Action": "sqs:SendMessage",
"Resource": "arn:aws:sqs:ap-east-1:123456789012:prod-platform-checkout-order-payment-capture",
"Condition": {
"ArnEquals": {
"aws:SourceArn": "arn:aws:sns:ap-east-1:123456789012:prod-platform-checkout-order-events"
}
}
}
]
}4. Encryption#
SSE-SQS:
AWS managed encryption for SQS
simple default for most queues
SSE-KMS:
use customer managed KMS key
better key policy / audit / rotation control
producers and consumers need KMS permissions
important:
encrypted queues require HTTPS and SigV4
SSE encrypts message body
queue metadata, message metadata, and metrics are not encrypted by SQS SSEKMS key policy/role permissions must allow:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowSqsKmsUsage",
"Effect": "Allow",
"Action": [
"kms:Decrypt",
"kms:GenerateDataKey"
],
"Resource": "arn:aws:kms:ap-east-1:123456789012:key/11111111-2222-3333-4444-555555555555"
}
]
}