AWS SNS to slack notifications handler for AWS Lambda
Assuming you already have SNS topic with subscribed lambda...
-
Create node project and add dependency:
npm install sns2slack
-
Create
index.js
file with following content:
const sns2slack = require("sns2slack");
exports.handler = sns2slack();
-
Zip your project file and upload it to AWS Lambda.
-
Setup environment variables:
SLACK_URL
- slack webhook integration urlSLACK_ENCRYPTED_URL
- AWS KMS encrypted value ofSLACK_URL
SLACK_CHANNEL
- default slack channel name (you can override this value by map function)SLACK_USER_NAME
- slack user name (default:AWS SNS
)SLACK_USER_ICON
- slack user icon (default::aws:
)
sns2slack(options)
: lambda handler function
options
:
map(snsMessage)
: optional function for transforming and filtering messages (return null to filter the log)