Primary Menu

AWS SNS and SQS Example using NodeJS

Using SNS and SQS and Example using NodeJS

Motivation

I wanted to test out using the new aws-sdk with Amazon Web Services (AWS) SNS and SQS services. It is now possible to subscribe queues to topics therefore creating a pub/sub style system without any system configuration work.

Setup at AWS

I created a new IAM user in the AWS console and attached the User Policies for Amazon SQS Full Access and Amazon SNS Full Access.

Code

Then I created code to generate the topic, queue and to subscribe the queue to the topic. By doing it this way the configuration is stored in code. No need to log into the AWS console and click through their interface.

Now I can publish messages to the topic and consume them from the queue.

Just curious how you came to these prices ($1.50 per message / second).

SQS Pricing :
First 1 million Amazon SQS Requests per month are free
$0.50 per 1 million Amazon SQS Requests per month thereafter ($0.00000050 per SQS Request)
A single request can have from 1 to 10 messages, up to a maximum total payload of 256KB.
Each 64KB ‘chunk’ of payload is billed as 1 request. For example, a single API call with a 256KB payload will be billed as four requests.