How do I customize message in SNS topic notification triggered on cloudwatch rules?

2.4k Views Asked by At

I have a cloudwatch alarm for my s3 bucket, if there are no changes to the bucket in a day, the alarm is triggered and an SNS topic is sent. I have set a cloudwatch event rule to schedule the target SNS topic daily if it meets the conditions.

However, I am having trouble customizing the SNS message needed to provided detail to the notifications. I have attempted to use the input transformer, but I cannot wrap my head around keys I need to map for this service.

How can I map the details required? How can I find the key-value details to send to my Input Transformer to formulate a message?

1

There are 1 best solutions below

0
On

The easiest method would be to trigger an AWS Lambda function that can read the incoming information, customize the content, and then send it as a message through Amazon SNS.

I don't think Amazon CloudWatch can directly trigger an AWS Lambda function, so you'll probably need two SNS topics:

  • One SNS topic used by CloudWatch, that triggers the Lambda function
  • One SNS topic that where Lambda sends the customized message and people can subscribe to receive it

The Lambda function can also do additional work, such as reporting on the size of the bucket and retrieving additional stats you would like mentioned.