From fd65016b3f484588990de5937c561762106f7d0f Mon Sep 17 00:00:00 2001 From: Benjamin Smith Date: Fri, 11 Feb 2022 08:32:24 -0800 Subject: [PATCH] Feature flag `enabled` monitors (#58) * allow enabling and disabling of particular monitors * update examples * Auto Format * update to use any and revert changes to monitors * Auto Format Co-authored-by: cloudpossebot <11232728+cloudpossebot@users.noreply.github.com> --- modules/monitors/main.tf | 2 +- modules/monitors/variables.tf | 61 ++++++++++++++++++----------------- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/modules/monitors/main.tf b/modules/monitors/main.tf index e04f542..e8eb77b 100644 --- a/modules/monitors/main.tf +++ b/modules/monitors/main.tf @@ -6,7 +6,7 @@ locals { # https://registry.terraform.io/providers/DataDog/datadog/latest/docs/resources/monitor resource "datadog_monitor" "default" { - for_each = local.enabled ? var.datadog_monitors : {} + for_each = local.enabled ? { for k, v in var.datadog_monitors : k => v if lookup(v, "enabled", true) } : {} name = each.value.name type = each.value.type diff --git a/modules/monitors/variables.tf b/modules/monitors/variables.tf index 2e15a22..aca4740 100644 --- a/modules/monitors/variables.tf +++ b/modules/monitors/variables.tf @@ -1,36 +1,37 @@ # https://registry.terraform.io/providers/DataDog/datadog/latest/docs/resources/monitor variable "datadog_monitors" { - type = map(object({ - name = string - type = string - message = string - escalation_message = string - query = string - tags = map(string) - notify_no_data = bool - new_group_delay = number - evaluation_delay = number - no_data_timeframe = number - renotify_interval = number - renotify_occurrences = number - renotify_statuses = set(string) - notify_audit = bool - timeout_h = number - enable_logs_sample = bool - include_tags = bool - require_full_window = bool - locked = bool - force_delete = bool - threshold_windows = map(any) - thresholds = map(any) - priority = number - groupby_simple_monitor = bool - validate = bool + type = any + # enabled = bool + # name = string + # type = string + # message = string + # escalation_message = string + # query = string + # tags = map(string) + # notify_no_data = bool + # new_group_delay = number + # evaluation_delay = number + # no_data_timeframe = number + # renotify_interval = number + # renotify_occurrences = number + # renotify_statuses = set(string) + # notify_audit = bool + # timeout_h = number + # enable_logs_sample = bool + # include_tags = bool + # require_full_window = bool + # locked = bool + # force_delete = bool + # threshold_windows = map(any) + # thresholds = map(any) + # priority = number + # groupby_simple_monitor = bool + # validate = bool - # TODO: deprecate in favor of new_group_delay once the options are fully clarified - # See https://github.com/DataDog/terraform-provider-datadog/issues/1292 - new_host_delay = number - })) + # TODO: deprecate in favor of new_group_delay once the options are fully clarified + # See https://github.com/DataDog/terraform-provider-datadog/issues/1292 + # new_host_delay = number + # })) description = "Map of Datadog monitor configurations. See catalog for examples" }