Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting notify_arns does not set {alarm,ok,insufficient_data}_actions #38

Open
LukasdeBoer opened this issue Jun 3, 2021 · 0 comments
Labels
bug 🐛 An issue with the system

Comments

@LukasdeBoer
Copy link
Contributor

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.

@LukasdeBoer LukasdeBoer added the bug 🐛 An issue with the system label Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An issue with the system
Projects
None yet
Development

No branches or pull requests

1 participant