Skip to content

Commit

Permalink
Feature flag enabled monitors (#58)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
Benbentwo and cloudpossebot authored Feb 11, 2022
1 parent 8a6abd5 commit fd65016
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 31 deletions.
2 changes: 1 addition & 1 deletion modules/monitors/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
61 changes: 31 additions & 30 deletions modules/monitors/variables.tf
Original file line number Diff line number Diff line change
@@ -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"
}

Expand Down

0 comments on commit fd65016

Please sign in to comment.