Skip to content

Commit fdcf2e4

Browse files
committed
Add instructions for setting up Slack notifications
1 parent 49b8e4b commit fdcf2e4

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

ci_tools/slack_notifications.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,42 @@ const AWS = require('aws-sdk');
44
const url = require('url');
55
const https = require('https');
66

7+
/*
8+
This code is intended to be used in an AWS Lambda function triggered by an Amazon CloudWatch Event rule with CodeBuild as source. This was written for demo purposes, and is probably not production ready.
9+
10+
Follow these steps to configure the webhook in Slack:
11+
12+
Navigate to https://.slack.com/services/new
13+
Search for and select "Incoming WebHooks".
14+
Choose the default channel where messages will be sent and click "Add Incoming WebHooks Integration".
15+
Copy the webhook URL from the setup instructions and use it in the next section.
16+
17+
To encrypt your secrets use the following steps:
18+
19+
Create or use an existing KMS Key - http://docs.aws.amazon.com/kms/latest/developerguide/create-keys.html
20+
Click the "Enable Encryption Helpers" checkbox
21+
Paste <SLACK_HOOK_URL> into the kmsEncryptedHookUrl environment variable and click encrypt Note: You must exclude the protocol from the URL (e.g. "hooks.slack.com/services/abc123").
22+
Give your function's role permission for the kms:Decrypt action.
23+
24+
Example:
25+
26+
{
27+
"Version": "2012-10-17",
28+
"Statement": [
29+
{
30+
"Sid": "Stmt1443036478000",
31+
"Effect": "Allow",
32+
"Action": [
33+
"kms:Decrypt"
34+
],
35+
"Resource": [
36+
"<your KMS key ARN>"
37+
]
38+
}
39+
]
40+
}
41+
*/
42+
743
// The base-64 encoded, encrypted key (CiphertextBlob) stored in the kmsEncryptedHookUrl environment variable
844
const kmsEncryptedHookUrl = process.env.kmsEncryptedHookUrl;
945
// The Slack channel to send a message to stored in the slackChannel environment variable

0 commit comments

Comments
 (0)