Skip to content

Instantly share code, notes, and snippets.

@Kyngo
Last active March 18, 2019 16:06
Show Gist options
  • Save Kyngo/74201a38fcd16c3ebd49ded4225d995b to your computer and use it in GitHub Desktop.
Save Kyngo/74201a38fcd16c3ebd49ded4225d995b to your computer and use it in GitHub Desktop.
AWS Lambda Function to send a message on Slack
// Simple slack messager for AWS Lambda
// I use it on my code to warn me if there's any runtime error.
const request = require("request");
const settings = require('./config.json');
exports.handler = (event, context, callback) => {
const options = {
method: 'POST',
url: settings.slack_webhook,
body: { text: event.message },
json: true
};
request(options, (error, response, body) => {
if (error) callback(error);
else {
callback(null, body);
}
});
}
{
"slack_webhook": "YOUR_SLACK_WEBHOOK_URL_HERE"
}
@Kyngo
Copy link
Author

Kyngo commented Mar 18, 2019

Yeah, simple as pie. But can be helpful, so here it is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment