Last active
March 18, 2019 16:06
-
-
Save Kyngo/74201a38fcd16c3ebd49ded4225d995b to your computer and use it in GitHub Desktop.
AWS Lambda Function to send a message on Slack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
} | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"slack_webhook": "YOUR_SLACK_WEBHOOK_URL_HERE" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah, simple as pie. But can be helpful, so here it is.