Skip to content

Commit

Permalink
need to convert from json string to dict when extracting message from…
Browse files Browse the repository at this point in the history
… event (#30)

* need to convert from json to dict here

* detect type of message, try to convert from json to dict
  • Loading branch information
alexgottscha authored and antonbabenko committed Feb 22, 2019
1 parent d835100 commit 1d2381a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions functions/notify_slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ def notify_slack(subject, message, region):
"icon_emoji": slack_emoji,
"attachments": []
}
if type(message) is str:
try:
message = json.loads(message)
except json.JSONDecodeError as err:
logging.exception(f'JSON decode error: {err}')
if "AlarmName" in message:
notification = cloudwatch_notification(message, region)
payload['text'] = "AWS CloudWatch notification - " + message["AlarmName"]
Expand Down

0 comments on commit 1d2381a

Please sign in to comment.