inopinatus

Jul 13, 2015 - 1 minute read - DevOps

Hook AWS notifications into Slack with a Lambda function

We have AWS RDS instances that send lifecycle notifications to an SNS topic. This was ending up in email, but I prefer to receive notifications in a Slack channel. Fortunately they are easy to integrate using AWS Lambda and Slack’s webhooks.

Here’s the Lambda function I’m using[1], which parses the message object (if it can) and formats the notifications before posting.

Note: the following links will require both AWS and Slack logins.
To do it yourself, create the webhook in Slack. Then publish the code above as a Lambda function in your AWS account (a basic execution role will be fine). Update line 5 with your own webhook URL. Have RDS notify a SNS topic and subscribe the Lambda function to that topic.

You can check the integration using Lambda’s standard SNS test event. For an end-to-end & event parsing test I suggest creating and deleting a RDS snapshot.

[1] derived with thanks from gist.github.com/vgeshel/1dba698aed9e8b39a464