Skip to content

Commit

Permalink
fix: Wrap try() with coalesce() to overcome non-null defaults (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkilchhofer authored Sep 11, 2024
1 parent c146ee5 commit 30c0917
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions grafana_alert.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ resource "grafana_rule_group" "this" {
annotations = {for k, v in rule.value.annotations : k => replace(v, "$value", "$values.QUERY_RESULT.Value")}
labels = merge(rule.value.labels, try(var.overrides[rule.value.alert].labels, {}))

exec_err_state = try(var.overrides[rule.value.alert].exec_err_state, "Error")
exec_err_state = coalesce(try(var.overrides[rule.value.alert].exec_err_state, null), "Error")
is_paused = try(var.overrides[rule.value.alert].is_paused, null)
no_data_state = try(var.overrides[rule.value.alert].no_data_state, "OK")
no_data_state = coalesce(try(var.overrides[rule.value.alert].no_data_state, null), "OK")

data {
ref_id = "QUERY"
Expand Down Expand Up @@ -101,7 +101,7 @@ resource "grafana_rule_group" "this" {
"conditions" = [
{
"evaluator" = {
"params" = [try(var.overrides[rule.value.alert].alert_threshold, 0)]
"params" = [coalesce(try(var.overrides[rule.value.alert].alert_threshold, null), 0)]
"type" = "gt"
}
"operator" = {
Expand Down

0 comments on commit 30c0917

Please sign in to comment.