Skip to content

Instantly share code, notes, and snippets.

@cplankey
Last active February 23, 2019 16:39
Show Gist options
  • Save cplankey/e95e976758cfa0abd455e1e8f12d338b to your computer and use it in GitHub Desktop.
Save cplankey/e95e976758cfa0abd455e1e8f12d338b to your computer and use it in GitHub Desktop.
A simple node module that takes a hostname, path, and msg to post to Slack from a Lambda Layer
//Takes a hostname, path, and msg to post to slack
var https = require("https");
exports.posttoslack = function(hostname, path, msg){
return new Promise((resolve, reject) => {
var options = {
"method": "POST",
"hostname": hostname,
"path": path,
"headers": {
"Content-Type": "application/json"
}
};
var req = https.request(options, (res) => {
resolve('Success');
});
req.on('error', (e) => {
reject(e.message);
});
// send the request
req.write(JSON.stringify({ text: msg }));
req.end();
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment