Get Instant Discord Alerts When AWS CloudWatch Alarms Fire
Automatically sends a formatted Discord message to your team channel whenever an AWS CloudWatch alarm changes state. Never miss a critical infrastructure alert again.
- 1
Create a Webhook trigger to receive SNS messages
Add a
Webhooknode as the trigger. SetHTTP Methodto POST and copy the generated URL. In n8n, note theTest URLfor testing andProduction URLfor live use. This endpoint will receive JSON payloads from AWS SNS. - 2
Parse and extract the SNS message body
Add a
Codenode connected to the Webhook. AWS SNS wraps the CloudWatch payload in aMessagestring field that is itself JSON. In the Code node, parse$json.body.MessagewithJSON.parse()to extract fields likeAlarmName,NewStateValue,NewStateReason, andStateChangeTime. Return these as a flat object. - 3
Check if the alarm state is ALARM or OK
Add an
IFnode to filter noise. Set the condition to check if{{ $json.NewStateValue }}equalsALARMon the true branch (critical alerts) orOKon the false branch (recovery notices). This lets you route or style messages differently per state. - 4
Send a formatted alert to Discord
Add an
HTTP Requestnode on the true branch. SetMethodto POST andURLto your Discord channel webhook URL (found in Discord under Channel Settings > Integrations > Webhooks). SetBody Content Typeto JSON and build the body with acontentfield:":red_circle: **ALARM** | {{ $json.AlarmName }}\nReason: {{ $json.NewStateReason }}\nTime: {{ $json.StateChangeTime }}". - 5
Send a recovery notice to Discord
Add a second
HTTP Requestnode on the false (OK) branch of the IF node. Use the same Discord webhook URL. Set thecontentfield to":green_circle: **RESOLVED** | {{ $json.AlarmName }}\nReason: {{ $json.NewStateReason }}\nTime: {{ $json.StateChangeTime }}"so your team knows the issue cleared.
Frequently asked questions
How do I connect AWS CloudWatch to this n8n webhook?
In AWS, create an SNS Topic and add an HTTPS subscription pointing to your n8n Production Webhook URL. Then open your CloudWatch alarm, go to Actions, and set it to notify that SNS Topic on state change. AWS will POST the alarm payload to n8n automatically.
AWS SNS sends a subscription confirmation request first — will that break the workflow?
Yes, the first request is a confirmation ping with a `SubscribeURL` field, not an alarm. You can handle this by adding a quick check in the Code node: if `$json.body.Type === 'SubscriptionConfirmation'`, return early or make an HTTP GET to the `SubscribeURL` to auto-confirm. After confirmation, real alarm payloads will flow through.
Can I send alerts to multiple Discord channels for different alarms?
Absolutely. Add more IF nodes to check `AlarmName` and branch to different `HTTP Request` nodes, each with a different Discord webhook URL. Alternatively, create separate n8n workflows with separate webhook endpoints and subscribe each SNS topic to the relevant endpoint.