Code Monkey home page Code Monkey logo

sns-to-slack's Introduction

SNS to Slack

SNS to Slack is a Serverless Lambda function written in both Node.js and Python for posting tiered SNS messages to Slack.

Architecture: Architecture diagram

  • 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 and SUCCESS messages and show them in Red, Yellow and Green

Tiered SNS Messages in Slack: Tiered SNS Messages in Slack

  • 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 or lambda.cfg for Python)
  • Caution:

    • The Lambda function must be set up to be triggered by SNS.
    • Each SNS message's message body must start with ERROR, WARNING or SUCCESS

How to Deploy Lambda Functions to AWS with the Serverless Framework

Deploy the Python version

  • 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 and serverless.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:

Deploy the node.js version

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

Reference

sns-to-slack's People

Contributors

beibeiyang avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.