Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SNS topic not publishing to SQS

I am trying to prototype a distributed application using SNS and SQS.I have this topic:

arn:aws:sns:us-east-1:574008783416:us-east-1-live-auction

and this queue:

arn:aws:sqs:us-east-1:574008783416:queue4

I created the queue using the JS Scratchpad. I added the subscription using the Console. I AddPermission to the queue using the scratchpad. The queue policy is now:

{      "Version":"2008-10-17",    "Id":"arn:aws:sqs:us-east-1:574008783416:queue4/SQSDefaultPolicy",    "Statement":[         {            "Sid":"RootPerms",          "Effect":"Allow",          "Principal":{               "AWS":"574008783416"          },          "Action":"SQS:*",          "Resource":"arn:aws:sqs:us-east-1:574008783416:queue4"       }    ] } 

I have an email subscription on the same topic and the emails arrive fine but the messages never arrive on the queue. I've tried SendMessage directly to the queue - rather than via SNS - using Scratchpad and it works fine. Any ideas why it won't send to the queue?

like image 993
user427875 Avatar asked May 08 '11 10:05

user427875


People also ask

How do I configure Amazon SNS topic to publish to the SQS queue?

In the navigation pane, choose Queues. From the list of queues, choose the queue to subscribe to the SNS topic. From Actions, choose Subscribe to Amazon SNS topic. From the Specify an Amazon SNS topic available for this queue menu, choose the SNS topic for your queue.

How do I confirm my SNS subscription to SQS?

To confirm the subscription, you can use the Amazon SQS console or the ReceiveMessage action. Before you subscribe an endpoint to the topic, make sure that the queue can receive messages from the topic by setting the sqs:SendMessage permission for the queue.

Is it possible to subscribe an SQS queue to an SNS topic?

Go to the SNS topic and click on the "Create subscription" button to create a subscription. Here, change the protocol to Amazon SQS and specify the ARN of the SQS topic in the endpoint field. Check the "Enable raw message delivery" checkbox and then click on the "Create subscription" button.


2 Answers

This was posted a while back on the AWS forums: https://forums.aws.amazon.com/thread.jspa?messageID=202798

Then I gave the SNS topic the permission to send messages to the SQS queue. The trick here is to allow all principals. SNS doesn't send from your account ID -- it has its own account ID that it sends from.

like image 200
Skyler Johnson Avatar answered Sep 16 '22 21:09

Skyler Johnson


Adding to Skyler's answer, if like me you cringe at the idea of allowing any principal (Principal: '*'), you can restrict the principal to SNS:

Principal:   Service: sns.amazonaws.com 

Although this behavior is undocumented, it works.

like image 20
spg Avatar answered Sep 17 '22 21:09

spg