From 678cfdc0dff1a8be0b2ac71c47a2922ac0619390 Mon Sep 17 00:00:00 2001 From: Chris Wright Date: Tue, 16 Jan 2024 17:34:24 +0000 Subject: [PATCH] Fix CloudWatch Slack Alerts Lambda message format * Creates a dict rather than creating a JSON string and loading it * Removes the 'return True', which is causing the function to exit early --- lambdas/cloudwatch-slack-alerts/function.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lambdas/cloudwatch-slack-alerts/function.py b/lambdas/cloudwatch-slack-alerts/function.py index 32bc28e..37ef52f 100644 --- a/lambdas/cloudwatch-slack-alerts/function.py +++ b/lambdas/cloudwatch-slack-alerts/function.py @@ -17,8 +17,8 @@ def lambda_handler(event, context): try: message = json.loads(event['Records'][0]['Sns']['Message']) except ValueError as e: - message = '{"message": "%s"}' (event['Records'][0]['Sns']['Message'].replace('"', '\\"')) - return True + message = { "message": event['Records'][0]['Sns']['Message'] } + logger.info("Message: " + str(message)) if "AlarmName" in message.keys():