Forward AWS CloudWatch Alarms and other notifications from Amazon SNS to Slack.
AWS-to-Slack is a Lambda function written in Node.js that forwards alarms and notifications to a dedicated Slack channel. It is 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 AWS product notification formats:
- Auto-Scaling Events
- Batch Events
- CloudFormation
- CloudWatch Alarms (incl. Metrics!)
- CodeBuild
- CodeCommit
- CodeDeploy 🆕 (via SNS/CloudWatch)
- CodePipeline 🆕 (via SNS/CloudWatch)
- CodePipeline Manual Approval 🆕
- Elastic Beanstalk
- GuardDuty 🆕
- Health Dashboard
- Inspector
- RDS
- SES Received Notifications
- Generic SNS messages
- Plain text messages
Additional formats will be added. Pull Requests are welcome!
Ready to try it for yourself? Installation into your own AWS environment is as
simple as pressing the button below (for installation outside of us-east-1
see details below):
THIS LINK DOES NOT MATCH MASTER BRANCH! We have been adding more event types and fixing bugs, but this link uses an old template. Pending a 2.0 release, please manually create a CloudFormation stack by uploading the cloudformation.yaml
from master branch!
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)
- Navigate to https://your-slack-domain.slack.com/apps/manage and click "Add Configuration".
- Choose the default channel where messages will be sent and click "Add Incoming WebHooks Integration".
- Copy the webhook URL from the setup instructions and use it in the next section.
- Click "Save Settings" at the bottom of the Slack integration page.
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.
Launch the CloudFormation Stack by using our preconfigured CloudFormation template or by simply pressing the following button:
Region | Launch Stack |
---|---|
us-east-1 | |
us-east-2 | |
us-west-1 | |
us-west-2 | |
ap-northeast-1 | |
ap-northeast-2 | |
ap-south-1 | |
ap-southeast-1 | |
ap-southeast-2 | |
ca-central-1 | |
eu-central-1 | |
eu-west-1 | |
eu-west-2 | |
eu-west-3 | |
sa-east-1 |
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.
Click "Next" again, complete the stack setup on the following pages and finally launch your stack.
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.
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.
Similar to the CodeBuild integration, CodeCommit notifications are triggered by CloudWatch Event Rules. Create a new CloudWatch Event Rule, select CodeCommit as the source, and select one of the supported event types:
- CodeCommit Pull Request State Change - Will generate events when a pull request is opened, closed, merged, or updated.
- CodeCommit Repository State Change - Will generate events when a branch or tag reference is created, updated, or deleted.
Add the aws-to-slack
lambda as the target. No other settings are needed.
You can save local .env
files that contain your stack configurations for easier deployment and updates. Copy targets/example.env
to a separate file and customize the parameters. Then deploy the file like this:
TARGET=targets/my-deploy.env make deploy
If you want to force-compile this project and push your code to a stack, use this:
TARGET=targets/my-deploy.env make package deploy
If you need to update your CloudFormation parameters, try this:
TARGET=targets/my-deploy.env make update-stack
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.
make package
This generates a new release.zip
in the root folder. Upload this zip to your
AWS Lambda function and you're good to go. Make sure to check out Managing Multiple Deployments for a more scalable solution to deploys.