SNS to Slack is a Serverless Lambda function written in both Node.js and Python for posting tiered SNS messages to Slack.
- Features
- Choose either Node.js or Python
- Deployed with the Serverless framework to AWS
- The Lambda function is triggered by SNS events
- Read SNS Notifications of any events
- Post SNS messages to your designated Slack channel
- Support of
ERROR
,WARNING
andSUCCESS
messages and show them in Red, Yellow and Green
-
Follow these steps to configure a webhook in Slack:
- Navigate to either
https://<your-team>.slack.com/apps
or https://api.slack.com/incoming-webhooks - Select "Incoming WebHooks"
- Click the "Create your Slack app" button and follow the wizard to complete the creation of your new app.
- Activate incoming webhooks for your app in the config page
- Click on "Add New Webhook to Workspace" and choose the default channel where SNS messages should be sent and click "Add Incoming WebHooks Integration".
- Copy the Webhook URL from the setup instructions and paste it into config file (
config.js
for Node.js orlambda.cfg
for Python)
- Navigate to either
-
Caution:
- The Lambda function must be set up to be triggered by SNS.
- Each SNS message's message body must start with
ERROR
,WARNING
orSUCCESS
- Prerequisites:
- Python 2.x / 3.x or Anaconda Python 2.x / 3.x
- Python virtual environment (such as virtualenv or conda)
- Install node.js and npm
- Install Docker
- Install Serverless:
npm install -g serverless
- Initialize NPM:
npm init
- Install Serverless Python Requirements:
npm install --save serverless-python-requirements
$ cd python
- Update
lambda.cfg
andserverless.yml
- Deploy Lambda:
export AWS_ACCESS_KEY_ID=<YOUR_AWS_ACCESS_KEY_ID>
export AWS_SECRET_ACCESS_KEY=<YOUR_AWS_SECRET_ACCESS_KEY>
serverless deploy
- Follow this guide to package Python in Lambda with Serverless plugins:
- Prerequisites:
- Install node.js and npm
- Install Serverless Framework - Follow along step 1-3 of this reference.
$ cd nodejs
- Update
config.js
andserverless.yml
- Deploy Lambda:
export AWS_ACCESS_KEY_ID=<YOUR_AWS_ACCESS_KEY_ID>
export AWS_SECRET_ACCESS_KEY=<YOUR_AWS_SECRET_ACCESS_KEY>
serverless deploy
- Follow this guide to package Nodejs in Lambda with Serverless plugins
- Serverless.yml Reference
- How to Handle your Python packaging in Lambda with Serverless plugins
- How to deploy a Node.js application to AWS Lambda using Serverless