Skip to content

Instantly share code, notes, and snippets.

@roydondsouza
Forked from jeremypruitt/sns-publish
Created February 4, 2017 19:42
Show Gist options
  • Save roydondsouza/9d5eeb8501b35b1caa2e92dc3a39c240 to your computer and use it in GitHub Desktop.
Save roydondsouza/9d5eeb8501b35b1caa2e92dc3a39c240 to your computer and use it in GitHub Desktop.
AWS Lambda function to publish to SNS topic
console.log('Loading function');
var AWS = require('aws-sdk');
AWS.config.region = 'us-west-2';
exports.handler = function(event, context) {
console.log("\n\nLoading handler\n\n");
var sns = new AWS.SNS();
sns.publish({
Message: 'Test publish to SNS from Lambda',
TopicArn: 'TOPIC_ARN'
}, function(err, data) {
if (err) {
console.log(err.stack);
return;
}
console.log('push sent');
console.log(data);
context.done(null, 'Function Finished!');
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment