Hi everyone,
I am working on an AWS cross-account integration where an S3 bucket in Account A triggers an SNS topic, which then sends messages to an SQS queue in Account B. The final step is a Lambda function in Account B that processes messages from the SQS queue.
FLOW: [(Account A )S3 -> Event Notification destination - SNS Topic ]-> [ (Account B) SQS Queue -> Trigger Lambda Function ]
Everything works when encryption is disabled, but as soon as both SNS and SQS use KMS encryption, messages do not get delivered to SQS.
I have tried multiple approaches and debugging steps, but no success so far. Hoping to get some insights from the community! 🙏 This is the end-to-end AWS architecture I am working on:
S3 Bucket (Account A) → Sends event notifications to SNS when an object is uploaded.
SNS Topic (Account A) → Publishes the event notification to an SQS queue in Account B.
SQS Queue (Account B) → Receives the event from SNS and triggers a Lambda function.
Lambda Function (Account B) → Processes the event and performs further actions.
What Works:
SNS successfully publishes messages to SQS when encryption is disabled.
SNS with encryption can send messages to an unencrypted SQS queue in another account.
Manually sending an encrypted message to SQS works.
What Fails:
I have used following policies
SNS KMS Key Policy (Account A) Ensured that SNS is allowed to encrypt messages before sending them to SQS.
{ "Version": "2012-10-17", "Id": "sns-key-policy", "Statement": [ { "Sid": "AllowRootAccountAccess", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::ACCOUNT_A_ID:root" }, "Action": "kms:", "Resource": "" }, { "Sid": "AllowSNSServiceToEncryptMessages", "Effect": "Allow", "Principal": { "Service": "sns.amazonaws.com" }, "Action": [ "kms:Encrypt", "kms:GenerateDataKey" ], "Resource": "" }, { "Sid": "AllowCrossAccountSQSQueue", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::ACCOUNT_B_ID:root" }, "Action": [ "kms:Decrypt", "kms:DescribeKey" ], "Resource": "" } ] }
2. SNS Topic Policy (Account A) { "Version": "2012-10-17", "Statement": [ { "Sid": "AllowSQSAccountBToSubscribe", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::ACCOUNT_B_ID:root" }, "Action": "sns:Subscribe", "Resource": "arn:aws:sns:REGION:ACCOUNT_A_ID:MyCrossAccountSNSTopic" }, { "Sid": "AllowSNSPublishToSQS", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::ACCOUNT_B_ID:root" }, "Action": "sns:Publish", "Resource": "arn:aws:sns:REGION:ACCOUNT_A_ID:MyCrossAccountSNSTopic" } ] }
3. SQS KMS Key Policy (Account B) Ensured SNS from Account A can encrypt messages and SQS can decrypt messages. { "Version": "2012-10-17", "Id": "sqs-key-policy", "Statement": [ { "Sid": "AllowRootAccountAccess", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::ACCOUNT_B_ID:root" }, "Action": "kms:", "Resource": "" }, { "Sid": "AllowSQSServiceToDecrypt", "Effect": "Allow", "Principal": { "Service": "sqs.amazonaws.com" }, "Action": [ "kms:Decrypt", "kms:DescribeKey" ], "Resource": "", "Condition": { "ArnEquals": { "aws:SourceArn": "arn:aws:sqs:REGION:ACCOUNT_B_ID:MyCrossAccountSQSQueue" } } }, { "Sid": "AllowSNSAccountAEncryption", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::ACCOUNT_A_ID:root" }, "Action": [ "kms:Encrypt", "kms:GenerateDataKey" ], "Resource": "", "Condition": { "ArnEquals": { "aws:SourceArn": "arn:aws:sns:REGION:ACCOUNT_A_ID:MyCrossAccountSNSTopic" } } } ] }
4. SQS Queue Policy (Account B) { "Version": "2012-10-17", "Statement": [ { "Sid": "AllowSNSFromAccountA", "Effect": "Allow", "Principal": { "Service": "sns.amazonaws.com" }, "Action": "sqs:SendMessage", "Resource": "arn:aws:sqs:REGION:ACCOUNT_B_ID:MyCrossAccountSQSQueue", "Condition": { "ArnEquals": { "aws:SourceArn": "arn:aws:sns:REGION:ACCOUNT_A_ID:MyCrossAccountSNSTopic" } } } ] }
Debugging Steps I tried
Enabled SNS Logging in CloudWatch
Checked CloudTrail logs for errors (no access denied messages)
Manually sent an encrypted message to SQS (it worked)
Verified SNS subscription to SQS is confirmed
SNS messages do not appear in the SQS queue when encryption is enabled. 🥲
No errors in CloudWatch logs related to SNS failing to send messages.
IMPORTANT: Open Questions for the Community
Are there any hidden KMS permission requirements for SNS and SQS that I might be missing?
Is there a way to force SNS to log detailed encryption failures?
Has anyone successfully set up SNS to SQS with cross-account KMS encryption? If so, how did you configure it?🙏🏻 🥺 Any help or insights would be highly appreciated! Thanks in advanrce. 🙏