DevOps · n8n

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.

difficulty Intermediatesetup 30 minresult A Discord notification with alarm name, state, reason, and timestamp is posted to your chosen channel the moment CloudWatch detects a problem.
  1. 1

    Create a Webhook trigger to receive SNS messages

    Add a Webhook node as the trigger. Set HTTP Method to POST and copy the generated URL. In n8n, note the Test URL for testing and Production URL for live use. This endpoint will receive JSON payloads from AWS SNS.

  2. 2

    Parse and extract the SNS message body

    Add a Code node connected to the Webhook. AWS SNS wraps the CloudWatch payload in a Message string field that is itself JSON. In the Code node, parse $json.body.Message with JSON.parse() to extract fields like AlarmName, NewStateValue, NewStateReason, and StateChangeTime. Return these as a flat object.

  3. 3

    Check if the alarm state is ALARM or OK

    Add an IF node to filter noise. Set the condition to check if {{ $json.NewStateValue }} equals ALARM on the true branch (critical alerts) or OK on the false branch (recovery notices). This lets you route or style messages differently per state.

  4. 4

    Send a formatted alert to Discord

    Add an HTTP Request node on the true branch. Set Method to POST and URL to your Discord channel webhook URL (found in Discord under Channel Settings > Integrations > Webhooks). Set Body Content Type to JSON and build the body with a content field: ":red_circle: **ALARM** | {{ $json.AlarmName }}\nReason: {{ $json.NewStateReason }}\nTime: {{ $json.StateChangeTime }}".

  5. 5

    Send a recovery notice to Discord

    Add a second HTTP Request node on the false (OK) branch of the IF node. Use the same Discord webhook URL. Set the content field 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.

About this recipe. Recipes on FlowRecipesHub are written for business owners, not developers, and are tested before publishing — how recipes get made. Some ingredient links are affiliate links that cost you nothing — full disclosure.