diff --git a/config.js b/config.js index ce51bc7..3f3563d 100644 --- a/config.js +++ b/config.js @@ -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: { @@ -27,4 +28,4 @@ module.exports = { } } -} \ No newline at end of file +} diff --git a/index.js b/index.js index c61ab4e..17c605f 100644 --- a/index.js +++ b/index.js @@ -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); @@ -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); @@ -430,7 +432,7 @@ exports.handler = function(event, context) { processEvent(event, context); } }); - } else { + }else { context.fail('hook url has not been set.'); } }; diff --git a/package.json b/package.json index 6e1e021..95eccb1 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "lambda-cloudwatch-slack", "version": "0.3.0", "description": "Better Slack notifications for AWS CloudWatch", - "authors": [ + "authors": [ "Christopher Reichert ", "Cody Reichert ", "Alexandr Promakh " @@ -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": { diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 8c49fc7..d29f7e9 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -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 \ No newline at end of file +cat .env | grep SLACK_CHANNEL > ./tmp/deploy.env +$NODE_LAMBDA deploy --configFile ./tmp/deploy.env