architecture, javascript

Publishing to AWS SNS topic

SNS is wonderful , supporting HTTP, email(No HTML markup), email-json, SQS and SMS (US only for now).

Basically it allows you to receive various types of notifications or an app subscribed via various protocols.

Let’s bypass discussion how to subscribe to a Topic , its pretty trivial and is very flexible (some thirdparty can receive an HTTP call based on a message that arrived, awesome, right? )

Here is an example using NodeJS and AWS node library of publishing a message.

var AWS = require('aws-sdk');
//don't hard code your credential 🙂
 AWS.config.update({accessKeyId: 'ZZZ', secretAccessKey: 'ZZZ', region: 'us-east-1'});

var sns = new AWS.SNS();
sns.publish(
{TopicArn:'arn:aws:sns:us-east-1:283fdfdf-warning', Message:"Just testing for now ", Subject: "testing "}
, function(err,data){
 if (err){
     log("Error sending a message "+err);
 }else{
     log("Sent message {0}".format(data.MessageID));
 }
 });

 

Share This:

Leave a Reply