Commit 071246c
authored
Add slack notification (#44)
* Added the Lambda function for the slack notification.
* Added the AWS resource for the slack notification lambda function and Webhook URL parameter. Also added new parameters for the SendNotification task for the CD2RefreshStateMachine that will be passed to the slack notification lambda function.
* Reverted the SNS topic name because it is unnecessary.
* Added the Slack Webhook URL secret name parameter value.
* Removed the response.text due to github code scanning alert.
* Added the If condition when deciding where to get the SNS Topic ARN depending on the CreateNotificationTopic condition.
* Removed the Lambda function code because we will use the existing SNS topic.
* Removed the Lambda function AWS resource and Slack related paramter because they are no longer needed.
* Updated the message format for SendNotification to match the one expected in the lambda function named ubcla-notifications-sns-slack-notification.
* Added a comma in the JSON format for the SNS message.
* Updated the Message format for the SendNotification because using the Sub function in the JSON caused an error during the cloudformation stack update.
* Removed quotes in the Message.$ parameter.
* Fixed the cfn linting error.
* Revert "Removed the Lambda function code because we will use the existing SNS topic."
This reverts commit b5118f8.
* Revert "Removed the Lambda function AWS resource and Slack related paramter because they are no longer needed."
This reverts commit 7a37c39.
* Reverted the previous changes for the Message value for the SendNotification step.
* Added a function for processing the processed CD2 table data and outputs the human readable message.
* Took out the inline IAM policy from SlackNotificationFunction and created a new IAM role for it.
* Removed unnecessary paramters from SendNotfication that I added previously.
* Added a step to transform the string message into the real data.
* Fixed the slack secret name references in the AWS resources.
* Removed the value for SlackWebHookURLSecretNameParameter. This value will be provided via the environment variables in the AWS Codepipeline.
* Changed the docker image source from docker.io to public.ecr.aws to prevent anonymous pull rate limits from Docker Hub during the CodeBuild.
* Added the AWS environment value in the sns message title to tell if the message is from staging or production.
* Commented the complete tables because it makes the notification too crowded. The failed tables are more important information for the notification.
* Added the error message part in the sync_table payload message because these information is missing in the sync_table output. Added the parameter called failed_error_messages in the PivotResults state in the step function.
* Added the lines to test if the failed_error_messages get passed correctly from the step function.
* Changed the output payload from the PivotResult to SendNotification state to send the entire input data. We will process the CD2 data update result in the Lambda function.
* Added generate_error_string() to generate a error string. Added get_ecs_log_url() to get the cloudwatch log url. Replaced the hardcoded error messages with generate_error_string() calls.
* Replaced the encoding for the forward slash in the cloudwatch log URL with the URL-encoded version.
* Encoding the forward slash in the cloudwatch log stream string.
* Fixing a typo in the cloudwatch log url template string.
* Changed the Error string format. Also added the condition to handle the case where the exception message is empty.
* Refactored the message processing part to reflect the input data format changes from the step function.
* Simplified the error format.
* Introduced red and green emojis in the slack notification message.
* Added the complete table with schema update.
* Shorten the message category headers.
* Removed failed_init and failed_sync because they are included under the failed section.
* Added 2 different thresholds for the number of failed tables. Added a conditional statement to provide different emojis depends on the number of failed tables. When there is a high number of failed tables, we will alert everyone in the notification channel in slack.
* Updated the slack emoji codes.
* Added the dubugging message for testing.
* Revert "Added the dubugging message for testing."
This reverts commit 496f107.
* Added the comment regarding the edge case where we use the exception class name in case the error message is missing.
* Simplified the slack notification title. Added the cloudformation stack name in the title in case you have multiple stacksets for multiple Canvas environments.
* Merged the failed tables and errors in the notification message.
* Fixed the missing bold tag for the notification title.
* Moved get_secret_value() and send_to_slack() into the shared folder because these functions will be used in multiple places.
* Created a lambda layer for shared functions for lambda functions.
* Added a step to properly name the environment type in the notification title.
* Moved the environment name conversion code as a separate function and put it into the lambda layer because it will be used in the multiple lambda functions. Removed sys.path.append() because it is not needed when referencing functions from the lambda layers.
* Added the slack notification message in case the list_tables operation fails for any reasons.
* Added the requests module for sending a slack message.
* Added the red x emoji for the listTables error.
* Added the permission to access the Slack Webhook URL from the AWS Secrets Manager for ListTablesRole for slack notification.
* Added comments.
* Changed the print() statement with the logger.exception().
* Removed the unnecessary instruction on what to do for the invalid_client error.
* Changed the LambdaLayer related names.
* Removed the parameters that has been commented out.1 parent 9df5e05 commit 071246c
File tree
12 files changed
+281
-26
lines changed- init_table
- list_tables
- slack_notification
- sync_table
12 files changed
+281
-26
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
Whitespace-only changes.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
26 | 40 | | |
27 | 41 | | |
28 | 42 | | |
29 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
30 | 48 | | |
31 | | - | |
32 | | - | |
| 49 | + | |
33 | 50 | | |
34 | | - | |
| 51 | + | |
35 | 52 | | |
36 | | - | |
| 53 | + | |
37 | 54 | | |
38 | | - | |
| 55 | + | |
39 | 56 | | |
40 | | - | |
| 57 | + | |
| 58 | + | |
41 | 59 | | |
42 | | - | |
43 | | - | |
| 60 | + | |
44 | 61 | | |
45 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
46 | 66 | | |
47 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
48 | 73 | | |
49 | 74 | | |
50 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
Whitespace-only changes.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
34 | 67 | | |
35 | 68 | | |
36 | 69 | | |
| |||
52 | 85 | | |
53 | 86 | | |
54 | 87 | | |
| 88 | + | |
| 89 | + | |
55 | 90 | | |
56 | 91 | | |
57 | 92 | | |
| |||
80 | 115 | | |
81 | 116 | | |
82 | 117 | | |
| 118 | + | |
| 119 | + | |
83 | 120 | | |
84 | 121 | | |
85 | 122 | | |
86 | 123 | | |
87 | 124 | | |
88 | 125 | | |
89 | 126 | | |
| 127 | + | |
90 | 128 | | |
91 | 129 | | |
92 | 130 | | |
93 | 131 | | |
94 | 132 | | |
95 | 133 | | |
| 134 | + | |
96 | 135 | | |
97 | 136 | | |
98 | 137 | | |
| 138 | + | |
99 | 139 | | |
100 | 140 | | |
101 | 141 | | |
| |||
105 | 145 | | |
106 | 146 | | |
107 | 147 | | |
108 | | - | |
109 | 148 | | |
110 | 149 | | |
111 | 150 | | |
| |||
176 | 215 | | |
177 | 216 | | |
178 | 217 | | |
179 | | - | |
| 218 | + | |
180 | 219 | | |
181 | | - | |
| 220 | + | |
182 | 221 | | |
183 | 222 | | |
184 | 223 | | |
| |||
0 commit comments