Send AWS CloudWatch Alarms to Slack

I have a few servers on AWS. Some information on those, e.g. high load, would be nice to be notified of. Preferably on Slack. How do I do that?

Part 1: Send alarms to an SNS Topic

Using awscli on a local machine, create a new SNS Topic. What’s an SNS Topic, you say? Think of a Topic as a bucket where your logs are pushed to, and your notification channels (SMS, Email, Slack++) subscribe to. It’s merely a logical grouping of notifications.

aws sns create-topic
--region eu-central-1
--name my-topic-name

Note down the returned TopicArn for part 2.

Then, let’s create an Alarm that posts to this Topic when an ELB gets a 500 error. Either with aws cli:

For Role: If you have the role lambda_basic_execution available, select that. If not, create it by selecting Create a custom role. It should automatically suggest a role that has a Policy document which allows the actions “logs:CreateLogGroup”, “logs:CreateLogStream”, and “logs:PutLogEvents”.

VPC: no VPC

You can test that your SNS posts to Slack by publishing to the SNS topic manually: