Skip to content

Commit

Permalink
Fix Alarm Notification Terraform
Browse files Browse the repository at this point in the history
  • Loading branch information
KamranBiglari committed Aug 10, 2023
1 parent d9dc29f commit ccde978
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
12 changes: 9 additions & 3 deletions example/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ module "cloudwatch-monitor" {
current_environment = "dev"
template_data = {
rediscluster = {}
websocketmonitoring = module.websocketmonitoring #
websocketmonitoring = module.websocketmonitoring
}
alarm_actions = {
default = {
alarm = ""
ok = ""
alarm = {
critical = ["arn:aws:sns:us-east-1:123456789012:critical"]
warning = ["arn:aws:sns:us-east-1:123456789012:critical"]
}
ok = {
critical = ["arn:aws:sns:us-east-1:123456789012:critical"]
warning = ["arn:aws:sns:us-east-1:123456789012:critical"]
}
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@ module "metric-alarm" {

actions_enabled = can(each.value.Config.AlarmActions) ? true : false
alarm_actions = [for aK, aV in each.value.Config.AlarmActions.ALARM :
try(var.alarm_actions[aK]["alarm"][aV[var.current_environment]].arn, "")
if can(var.alarm_actions[aK]["alarm"][aV[var.current_environment]].arn)
try(var.alarm_actions[aK]["alarm"][aV[var.current_environment]], "")
if can(var.alarm_actions[aK]["alarm"][aV[var.current_environment]])
]
ok_actions = [for aK, aV in each.value.Config.AlarmActions.OK :
try(var.alarm_actions[aK]["ok"][aV[var.current_environment]].arn, "")
if can(var.alarm_actions[aK]["ok"][aV[var.current_environment]].arn)
try(var.alarm_actions[aK]["ok"][aV[var.current_environment]], "")
if can(var.alarm_actions[aK]["ok"][aV[var.current_environment]])
]

depends_on = [ module.log-metric-filter ]

}

#CloudWatch Custom Metrics
Expand Down

0 comments on commit ccde978

Please sign in to comment.