This tool can be used to post alerts to a Slack channel when AWS Health events are generated by using AWS Lambda and Amazon CloudWatch Events.
Follow these steps to configure the webhook in Slack:
-
Navigate to https://<your-team-domain>.slack.com/apps
-
Search for and select "Incoming WebHooks".
-
Select "Add Configuration" and choose the default channel where messages will be sent. Then click "Add Incoming WebHooks Integration".
-
Copy the webhook URL from the setup instructions and use it in the AWS Setup section that follows.
Choose Launch Stack to launch the template in the US East (N. Virginia) Region in your account:
The CloudFormation template requires the following parameters:
SlackChannel - A Slack channel name where you would like the notifications to get pushed.
HookURL - Incoming web hook url from Slack setup.
-
Create an IAM role for the Lambda function to use. Attach the IAM policy to the role in the IAM console. Documentation on how to create an IAM policy is available here: http://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create.html Documentation on how to create an IAM role for Lambda is available here: http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html#roles-creatingrole-service-console
-
Create a Lambda Python function by using the sample provided and choose the IAM role created in step 1. Update the configuration section of the Lambda function with webhook URL from the Slack setup above and update the Slack channel that you want AWS Health messages posted in.
More information about Lambda is available here: http://docs.aws.amazon.com/lambda/latest/dg/getting-started.html More information about Slack integration with Lambda is available here: https://aws.amazon.com/blogs/aws/new-slack-integration-blueprints-for-aws-lambda/ -
Create a CloudWatch Events rule to trigger the Lambda function created in step 2 for AWS Health events. Documentation on how to create an AWS Health CloudWatch Events rule is available here: http://docs.aws.amazon.com/health/latest/ug/cloudwatch-events-health.html
More information about AWS Health is available here: http://docs.aws.amazon.com/health/latest/ug/what-is-aws-health.html
Note that this is a just an example of how to set up automation with AWS Health, Amazon CloudWatch Events, and AWS Lambda. We recommend testing the example and tailoring it to your environment before using it in your production environment.
AWS Health Tools are licensed under the Apache 2.0 License.