Skip to content

Commit

Permalink
feat: add support for GovCloud URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Kania committed Oct 26, 2020
1 parent abef34f commit db1aec7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion functions/notify_slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ def decrypt(encrypted_url):

def cloudwatch_notification(message, region):
states = {'OK': 'good', 'INSUFFICIENT_DATA': 'warning', 'ALARM': 'danger'}
if region.startswith("us-gov-"):
cloudwatch_url = "https://console.amazonaws-us-gov.com/cloudwatch/home?region="
else:
cloudwatch_url = "https://console.aws.amazon.com/cloudwatch/home?region="

return {
"color": states[message['NewStateValue']],
Expand All @@ -30,7 +34,7 @@ def cloudwatch_notification(message, region):
{ "title": "Current State", "value": message['NewStateValue'], "short": True },
{
"title": "Link to Alarm",
"value": "https://console.aws.amazon.com/cloudwatch/home?region=" + region + "#alarm:alarmFilter=ANY;name=" + urllib.parse.quote(message['AlarmName']),
"value": cloudwatch_url + region + "#alarm:alarmFilter=ANY;name=" + urllib.parse.quote(message['AlarmName']),
"short": False
}
]
Expand Down

0 comments on commit db1aec7

Please sign in to comment.