-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsns.sample.js
More file actions
36 lines (34 loc) · 809 Bytes
/
sns.sample.js
File metadata and controls
36 lines (34 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var AWS = require("aws-sdk");
var sns = new AWS.SNS();
exports.handler = function(event, context) {
console.log(event);
if ([
"YOUR_SLACK_SLASH_COMMAND_TOKEN"
].indexOf(event.token) === -1) {
return context.fail("Unauthorized Request")
}
sns.publish({
Message: JSON.stringify({
"default": JSON.stringify(event)
}),
MessageStructure: 'json',
TopicArn: 'YOUR_SNS_TOPIC_ARN'
}, function(error, data) {
if (error) {
console.log(error);
return context.succeed({
"response_type": "ephemeral",
"attachments": [
{
"text": "YOUR_SOMETHING_ERROR_MSG",
"color": "danger"
}
]
});
} else {
return context.succeed({
"response_type": "in_channel"
});
}
});
};