hendry
hendry

Reputation: 10813

How to listen to SNS messages from the CLI to test they have been sent?

I'm looking for a way to listen arbitrarily to my SNS Topic, and in parallel trigger a SNS message from my code base. Next I need to test if that message was sent correctly.

code-that-listens-and-exits-when-it-gets-hello-world-message
aws sns publish --topic-arn arn:aws:sns:ap-southeast-1:123456789:hello --message "Hello World!"

I find plenty of information how to subscribe to a topic from the CLI, but I am puzzled how to actually listen or test for the event coming through the topic. Which protocol should I be using? I don't want to go down the route of checking a subscribed email endpoint contains the message in the inbox.

Upvotes: 3

Views: 5295

Answers (2)

andrew
andrew

Reputation: 3899

I wrote a tool for this: ontopic. It's a cli tool that creates an SQS queue on startup, subscribes it to the topic and starts polling the queue. Before the process dies the queue and the subscription are removed.

Upvotes: 1

dpwr
dpwr

Reputation: 2812

Simple answer is that you can't do that. You could configure a lambda subscriber to output the messages to a log or something and then watch that from the CLI.

If you want to subscribe an arbitrary client to a queue of messages, then SQS might be more suitable.

Upvotes: 1

Related Questions