Skip to main content
The Lambda function detects CloudWatch alarm events by checking for the presence of an AlarmName key in the SNS message body. When found, it routes the message to the CloudWatch alarm formatter.

Alarm states and colors

Each alarm state maps to a Slack attachment color via the CloudWatchAlarmState enum:
StateSlack colorAppearance
OKgoodGreen
INSUFFICIENT_DATAwarningYellow
ALARMdangerRed

Fields in the Slack message

The formatted Slack attachment includes the following fields:
FieldDescription
Alarm NameThe name of the CloudWatch alarm
Alarm DescriptionThe description set on the alarm
Alarm reasonThe NewStateReason — why the state changed
Old StateThe previous alarm state (OldStateValue)
Current StateThe new alarm state (NewStateValue)
Link to AlarmDirect link to the alarm in the CloudWatch console

Example SNS message payload

This is the structure of the CloudWatch alarm notification that arrives in the SNS message body:
{
  "AlarmName": "Example",
  "AlarmDescription": "Example alarm description.",
  "AWSAccountId": "000000000000",
  "NewStateValue": "ALARM",
  "NewStateReason": "Threshold Crossed",
  "StateChangeTime": "2017-01-12T16:30:42.236+0000",
  "Region": "EU - Ireland",
  "OldStateValue": "OK"
}

Connecting CloudWatch alarms to the SNS topic

You can send alarm state changes to the SNS topic in two ways.

Build docs developers (and LLMs) love