Skip to content

Commit 18d63e3

Browse files
committed
parse sns event when notify it to slack
1 parent bd47e70 commit 18d63e3

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

functions/notify_to_slack.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,23 @@ const notifyToSlack = require('./notify_to_slack/index');
44

55
module.exports.handle = (event, context, callback) => {
66

7-
notifyToSlack(event);
7+
let notification = event;
8+
9+
if(event.Records[0].Sns) {
10+
notification = parseSnsEvent(event);
11+
}
12+
13+
notifyToSlack(notification);
814
callback(null, {});
915

1016
};
1117

18+
function parseSnsEvent(event) {
19+
const sns = event.Records[0].Sns;
20+
21+
return {
22+
Subject: sns.Subject,
23+
Message: JSON.parse(sns.Message),
24+
}
25+
}
26+

0 commit comments

Comments
 (0)