Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
kmsEncryptedHookUrl: process.env.KMS_ENCRYPTED_HOOK_URL, // encrypted slack webhook url
unencryptedHookUrl: process.env.UNENCRYPTED_HOOK_URL, // unencrypted slack webhook url
slackChannel: process.env.SLACK_CHANNEL, // slack channel

services: {
elasticbeanstalk: {
Expand All @@ -27,4 +28,4 @@ module.exports = {
}
}

}
}
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ var config = require('./config');
var _ = require('lodash');
var hookUrl;

var baseSlackMessage = {}
var channel = config.slackChannel;

var baseSlackMessage = {"channel": channel}

var postMessage = function(message, callback) {
var body = JSON.stringify(message);
Expand Down Expand Up @@ -412,7 +414,7 @@ var processEvent = function(event, context) {

exports.handler = function(event, context) {
if (hookUrl) {
processEvent(event, context);
processEvent(event, context);
} else if (config.unencryptedHookUrl) {
hookUrl = config.unencryptedHookUrl;
processEvent(event, context);
Expand All @@ -430,7 +432,7 @@ exports.handler = function(event, context) {
processEvent(event, context);
}
});
} else {
}else {
context.fail('hook url has not been set.');
}
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "lambda-cloudwatch-slack",
"version": "0.3.0",
"description": "Better Slack notifications for AWS CloudWatch",
"authors": [
"authors": [
"Christopher Reichert <creichert07@gmail.com>",
"Cody Reichert <codyreichert@gmail.com>",
"Alexandr Promakh <s-promakh@ya.ru>"
Expand All @@ -13,7 +13,7 @@
"dependencies": {
"aws-sdk": "^2.4.0",
"https": "^1.0.0",
"lodash": "^4.15.0",
"lodash": "^4.17.15",
"url": "^0.11.0"
},
"devDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ NODE_LAMBDA=./node_modules/node-lambda/bin/node-lambda
test -s $NODE_LAMBDA || { echo "node-lambda not installed. Run 'npm install' first."; exit 1; }
mkdir -p tmp
cat .env | grep HOOK_URL > ./tmp/deploy.env
$NODE_LAMBDA deploy --configFile ./tmp/deploy.env
cat .env | grep SLACK_CHANNEL > ./tmp/deploy.env
$NODE_LAMBDA deploy --configFile ./tmp/deploy.env