-
-
Notifications
You must be signed in to change notification settings - Fork 23
Description
Describe the Bug
This module exposes 4 different variables to set ARNs that the cloudwatch alarms will set as their actions:
notify_arns
alarm_actions
ok_actions
insufficient_data_actions
The idea being that when you only set notify_arns
, it will set the other action arns for you, so you don't have to pass the same variable three times. This works using a coalescelist
on one of the actions, and the notify_arn
, to get the arn it needs (https://github.com/cloudposse/terraform-aws-alb-target-group-cloudwatch-sns-alarms/blob/master/main.tf#L43)
# default to using notify_arns unless a more specific action is specified.
alarm_actions = compact(coalescelist(var.alarm_actions, var.notify_arns))
ok_actions = compact(coalescelist(var.ok_actions, var.notify_arns))
insufficient_data_actions = compact(coalescelist(var.insufficient_data_actions, var.notify_arns))
This worked fine, until #18 was merged. This PR changed the default value of var.alarm_actions
, var.ok_actions
and var.insufficient_data_actions
from []
to [""]
, giving coalescelist
a significantly different behaviour.
According to the terraform docs, coalescelist takes any number of list arguments and returns the first one that isn't empty. However, it does not consider a list containing an empty string as an empty list:
terraform console
:
coalescelist([], [""], ["test"])
[
"",
]
We would like to get "test"
returned here, but in fact it returns the array containing an empty string.
Expected Behavior
I expect that when you set an ARN as notify_arns
, and do not set alarm_actions
, ok_actions
and insufficient_data_actions
, that the module still sets the alarms alarm_actions
, ok_actions
, and insufficient_data_actions
to notify_arns
.
Steps to Reproduce
Set an ARN as notify_arns
, do not set alarm_actions
, ok_actions
and insufficient_data_actions
. This module will create cloudwatch alarms without actions. If you pass the arn as alarm_actions
, ok_actions
and insufficient_data_actions
, it will set the alarms.
Environment (please complete the following information):
Tried this module's latest version (0.15.0) with latest Terraform 0.13.7, 0.14.11, 0.15.5.