Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine which SNS topics a SQS queue is subscribed to

Is there a way to list all of the AWS SNS topics that a particular SQS queue is subscribed to, using the AWS CLI?

I already know how to see the list of subscribers on an SNS topic, but that only works if I know the name of the SNS topic. In this case, I only know the name of the SQS queue.

I wasn't able to find anything by searching the interwebs.

like image 987
GreenGiant Avatar asked Mar 20 '18 17:03

GreenGiant


People also ask

How do I check my SQS subscription?

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?

You can subscribe one or more Amazon SQS queues to an Amazon Simple Notification Service (Amazon SNS) topic. When you publish a message to a topic, Amazon SNS sends the message to each of the subscribed queues. Amazon SQS manages the subscription and any necessary permissions.

How many subscriptions can an SQS queue have?

A single Amazon SQS message queue can contain an unlimited number of messages. However, there is a quota of 120,000 for the number of inflight messages for a standard queue and 20,000 for a FIFO queue.

Can SNS read from SQS?

SQS cannot publish messages to SNS. SQS can only store the messages. You have to pull the message using SQS Api's.


1 Answers

There is no such API for this purpose, so as a work around you can use SNS cli command aws sns list-subscriptions and filter by your SQS arn (using a grep command maybe). This approach may not be feasible depending on how many subscriptions exists on you account (results are paginated in a 100 items batch). You can filter subcriptions by topic to reduce results by using list-subscriptions-by-topic.

like image 59
Renato Gama Avatar answered Sep 28 '22 20:09

Renato Gama