Skip to content

Commit 537921a

Browse files
Merge pull request #6 from RohitSquareops/Release-bug-fixes
updated readme and variable for slack
2 parents ec4855c + 8638f2d commit 537921a

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

examples/complete-psql-replica/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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"

examples/complete/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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"

main.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ EOF
244244
}
245245

246246
data "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

254255
module "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

275277
resource "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

282285
resource "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
}

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
237243
variable "slack_webhook_url" {
238244
description = "The Slack Webhook URL where notifications will be sent."
239245
default = ""

0 commit comments

Comments
 (0)