/aws-to-slack

Forward AWS CloudWatch Alarms and other notifications from Amazon SNS to Slack.

Primary LanguageJavaScriptMIT LicenseMIT

AWS-to-Slack

npm license dependencies

Forward AWS CloudWatch Alarms and other notifications from Amazon SNS to Slack.

CloudWatch Alarm Example

Elastic Beanstalk Example

What is it?

AWS-to-Slack is a Lambda function written in Node.js that forwards alarms and notifications to a dedicated Slack channel. It self-hosted in your own AWS environment and doesn't have any 3rd party dependencies other than the Google Charts API for rendering CloudWatch metrics.

Supported notification formats:

  • AWS Code Build
  • AWS Health Dashboard 🆕
  • Amazon Inspector
  • Amazon SES Received Notifications 🆕
  • CloudWatch Alarms (incl. Metrics)
  • Elastic Beanstalk
  • RDS
  • Generic SNS messages
  • Plain text messages

Additional formats will be added; Pull Requests are welcome!

Try!

Ready to try it for yourself?

If you are in the us-east-1 AWS Region:

Installation into your own AWS environment is as simple as pressing the button below

Launch CloudFormation Stack

If you are not in the us-east-1 AWS Region

Please refer to the installation instructions below

Installation

Step 1 - Setup Slack

The Lambda function communicates with Slack through a Slack webhook webhook. Note that you can either create an app, or a custom integration > Incoming webhook (easier, will only let you add a webhook)

  1. Navigate to https://your-slack-domain.slack.com/apps/manage and click "Add Configuration".
  2. Choose the default channel where messages will be sent and click "Add Incoming WebHooks Integration".
  3. Copy the webhook URL from the setup instructions and use it in the next section.
  4. Click "Save Settings" at the bottom of the Slack integration page.

Slack Configuration

Step 2 - Configure & Launch the CloudFormation Stack

Note that the AWS region will be the region from which you launch the CloudFormation wizard, which will also scope the resources (SNS, etc.) to that region.

If you are launching the CloudFormation Wizard for us-east-1 resources:

Launch the CloudFormation Stack by using our preconfigured CloudFormation template or by simply pressing the following button:

Launch CloudFormation Stack

If you are not in the us-east-1 AWS Region:

  • Download the release.zip file and upload it so some AWS S3 Bucket (it only works with s3 URLs, plus the format must be s3://your-bucket/path-to-file.
  • Give public access to this file in S3
  • Make a copy of the cloudformation.yaml file, edit the s3 URL so that it points to your newly uploaded file s3 URL
  • Go to the CloudFormation interface from you region (you can click one of the links above, but make sure to change the region to yours) then click on "upload from file" and send your modified cloudformation.yaml file

Afterwards

Click "Next" and on the following page name your new stack and paste the webhook URL from before into the "HookUrl" field. You can also configure a different channel to post to if wanted.

AWS CloudFormation Configuration

Click "Next" again, complete the stack setup on the following pages and finally launch your stack.

Step 3 - Subscribe to Triggers

Before the Lambda function will actually do anything you need to subscribe it to actual CloudWatch alarms and other SNS triggers. Open up the AWS Lambda, switch to the "Triggers" tab and subscribe for all events you're interested in.

Lambda Triggers

Setting Up AWS CodeBuild

CodeBuild integration was suggested by ericcj and is based on the Medium post Monitor your AWS CodeBuilds via Lambda and Slack by Randy Findley.

To enable CodeBuild notifications add a new CloudWatch Event Rule, choose CodeBuild as source and CodeBuild Build State Change as type. As Target select the aws-to-slack Lambda. You can leave all other settings as is. Once your rule is created all CodeBuild build state events will be forwarded to your Slack channel.

Contributing

You want to contribute? That's awesome! 🎉

Check out our issues page for some ideas how to contribute and a list of open tasks. There're plenty of notification formats that still need to be supported.

The repository comes with a very simple Makefile to build the CloudFormation stack yourself. Simply run

make deps
make package

To generate a new release.zip in the build folder. Upload this zip to your AWS Lambda function and you're good to go.