File tree Expand file tree Collapse file tree 4 files changed +14
-2
lines changed
Expand file tree Collapse file tree 4 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,7 @@ module "rds-pg" {
107107 cloudwatch_metric_alarms_enabled = true
108108 alarm_cpu_threshold_percent = 70
109109 disk_free_storage_space = " 10000000" # in bytes
110+ slack_notification_enabled = false
110111 slack_username = " Admin"
111112 slack_channel = " postgresql-notification"
112113 slack_webhook_url = " https://hooks/xxxxxxxx"
Original file line number Diff line number Diff line change @@ -121,6 +121,7 @@ module "rds-pg" {
121121 cloudwatch_metric_alarms_enabled = true
122122 alarm_cpu_threshold_percent = 70
123123 disk_free_storage_space = " 10000000" # in bytes
124+ slack_notification_enabled = false
124125 slack_username = " Admin"
125126 slack_channel = " postgresql-notification"
126127 slack_webhook_url = " https://hooks/xxxxxxxx"
Original file line number Diff line number Diff line change 244244}
245245
246246data "archive_file" "lambdazip" {
247+ count = var. slack_notification_enabled ? 1 : 0
247248 type = " zip"
248249 output_path = " ${ path . module } /lambda/sns_slack.zip"
249250
@@ -252,6 +253,7 @@ data "archive_file" "lambdazip" {
252253
253254
254255module "cw_sns_slack" {
256+ count = var. slack_notification_enabled ? 1 : 0
255257 source = " ./lambda"
256258
257259 name = format (" %s-%s-%s" , var. environment , var. name , " sns-slack" )
@@ -273,16 +275,18 @@ module "cw_sns_slack" {
273275}
274276
275277resource "aws_sns_topic_subscription" "slack-endpoint" {
276- endpoint = module. cw_sns_slack . arn
278+ count = var. slack_notification_enabled ? 1 : 0
279+ endpoint = module. cw_sns_slack [0 ]. arn
277280 protocol = " lambda"
278281 endpoint_auto_confirms = true
279282 topic_arn = aws_sns_topic. slack_topic [0 ]. arn
280283}
281284
282285resource "aws_lambda_permission" "sns_lambda_slack_invoke" {
286+ count = var. slack_notification_enabled ? 1 : 0
283287 statement_id = " sns_slackAllowExecutionFromSNS"
284288 action = " lambda:InvokeFunction"
285- function_name = module. cw_sns_slack . arn
289+ function_name = module. cw_sns_slack [ 0 ] . arn
286290 principal = " sns.amazonaws.com"
287291 source_arn = aws_sns_topic. slack_topic [0 ]. arn
288292}
Original file line number Diff line number Diff line change @@ -234,6 +234,12 @@ variable "ok_actions" {
234234 default = []
235235}
236236
237+ variable "slack_notification_enabled" {
238+ type = bool
239+ description = " Whether to enable/disable slack notification."
240+ default = false
241+ }
242+
237243variable "slack_webhook_url" {
238244 description = " The Slack Webhook URL where notifications will be sent."
239245 default = " "
You can’t perform that action at this time.
0 commit comments