Skip to content

Instantly share code, notes, and snippets.

@Udith
Created February 20, 2018 08:39
Show Gist options
  • Save Udith/14f3d1e1c0d9152fb512426cac1e7cb3 to your computer and use it in GitHub Desktop.
Save Udith/14f3d1e1c0d9152fb512426cac1e7cb3 to your computer and use it in GitHub Desktop.
/*
This function publishes the provided message with subject to the notification
topic and excute the provided onSuccess or onFailure callback handler
*/
exports.sendNotification = (subject, message, onSuccess, onFailure) => {
sns.publish({
Message: message,
Subject: subject,
MessageAttributes: {},
MessageStructure: 'String',
TopicArn: 'arn:aws:sns:us-east-1:YOUR_ACCOUNT_ID:batch-process-notify'
}).promise()
.then(data => {
console.log("Successfully published notification");
onSuccess();
})
.catch(err => {
console.log("Error occurred while publishing notification", err, err.stack);
onFailure(err);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment