MON-301: Refactor a bit terraform code with intermediate locals
This commit is contained in:
parent
5acbe5045c
commit
e564cf068d
@ -1,4 +1,7 @@
|
|||||||
locals {
|
locals {
|
||||||
including = "${var.filter_tags_use_defaults == "true" ? join(",", compact(concat(split(",", format("dd_monitoring:enabled,dd_%s:enabled,env:%s", var.resource, var.environment)), compact(var.extra_tags)))) : "${var.filter_tags_custom}"}"
|
including_default_list = "${compact(concat(split(",", format("dd_monitoring:enabled,dd_%s:enabled,env:%s", var.resource, var.environment)), compact(var.extra_tags)))}"
|
||||||
excluding = "${join(",", compact(split(",", "${var.filter_tags_custom_excluded}")))}"
|
excluding_list = "${compact(split(",", "${var.filter_tags_custom_excluded}"))}"
|
||||||
|
|
||||||
|
including_string = "${var.filter_tags_use_defaults == "true" ? join(",", local.including_default_list) : "${var.filter_tags_custom}"}"
|
||||||
|
excluding_string = "${join(",", local.excluding_list)}"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
output "query_alert" {
|
output "query_alert" {
|
||||||
description = "The full filtering pattern including parentheses for service check monitor type"
|
description = "The full filtering pattern including parentheses for service check monitor type"
|
||||||
value = "{${join(",", compact(concat(list(local.including), formatlist("!%s", compact(split(",", local.excluding))))))}}"
|
value = "{${join(",", compact(concat(list(local.including_string), formatlist("!%s", local.excluding_list))))}}"
|
||||||
}
|
}
|
||||||
|
|
||||||
output "service_check" {
|
output "service_check" {
|
||||||
description = "The full filtering pattern including braces for query alert monitor type"
|
description = "The full filtering pattern including braces for query alert monitor type"
|
||||||
value = ".over(\"${replace(local.including, ",", "\",\"")}\")${local.excluding == "" ? "" : ".exclude(\"${replace(local.excluding, ",", "\",\"")}\")"}"
|
value = ".over(\"${replace(local.including_string, ",", "\",\"")}\")${local.excluding_string == "" ? "" : ".exclude(\"${replace(local.excluding_string, ",", "\",\"")}\")"}"
|
||||||
}
|
}
|
||||||
|
|
||||||
output "event_alert" {
|
output "event_alert" {
|
||||||
description = "The full filtering pattern for event alert monitor type"
|
description = "The full filtering pattern for event alert monitor type"
|
||||||
value = "tags:${local.including}${local.excluding == "" ? "" : " excluded_tags:${local.excluding}"}"
|
value = "tags:${local.including_string}${local.excluding_string == "" ? "" : " excluded_tags:${local.excluding_string}"}"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user