13

Currently, for triggering a lambda function in response to a CloudWatch alarm, I need to route the alarm via SNS, like this:

AWS CloudWatch Alarm --> Send to a topic in SNS --> SNS topic triggers the lambda function

So, is there a way I can do it directly, without SNS in the middle? [Reason: Less touch points and a bit of cost optimization].

CloudWatch events trigger lambda but there is no way I can trigger alarms via it. The only options available in CloudWatch events for SQS are:

enter image description here

030
  • 13,235
  • 16
  • 74
  • 173
Dawny33
  • 2,816
  • 3
  • 23
  • 62
  • Possible duplicate of http://stackoverflow.com/questions/34800976/how-to-connect-a-cloudwatch-alarm-to-a-lambda-function – Alexandre Mar 02 '17 at 20:00
  • It is possible to trigger Lambda function from CloudWatch alarm https://aws.amazon.com/about-aws/whats-new/2023/12/amazon-cloudwatch-alarms-lambda-change-action/ – Tomas.R Jan 18 '24 at 07:59

2 Answers2

10

As far as I know, it is not possible. The the offcial AWS Lambda documentation says it support CloudWatch Events, but no mention of CloudWatch Alarms (and CW Events != CW Alarms)

What you are currently doing, sending the alarms on a SNS and using listening on a topic seems the way to go. In fact, CloudWatch Alarms only outputs to SNS so far.

Alexandre
  • 1,965
  • 14
  • 24
1

It is possible to trigger Lambda function from CloudWatch alarm, by using EventBridge https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch-and-eventbridge.html

Anggra S
  • 11
  • 1