diff --git a/grafana_alert.tf b/grafana_alert.tf index dd39c72..966a1b1 100644 --- a/grafana_alert.tf +++ b/grafana_alert.tf @@ -1,10 +1,9 @@ resource "grafana_rule_group" "this" { -# for_each = local.file_as_yaml.groups for_each = local.alertsfile_map - name = each.value.name - folder_uid = var.folder_uid - org_id = var.org_id + name = each.value.name + folder_uid = var.folder_uid + org_id = var.org_id # There is no function supporting Golang's "duration" (format of interval within an alert group) # Use timeadd() function which supports it. @@ -17,7 +16,7 @@ resource "grafana_rule_group" "this" { disable_provenance = var.disable_provenance dynamic "rule" { - for_each = {for rule in each.value.rules: rule.alert => rule} + for_each = { for rule in each.value.rules : rule.alert => rule } content { name = rule.value.alert @@ -28,7 +27,7 @@ resource "grafana_rule_group" "this" { for k, v in merge(rule.value.annotations, try(var.overrides[rule.value.alert].annotations, {})) : k => replace(v, "$value", "$values.QUERY_RESULT.Value") } - labels = merge(rule.value.labels, try(var.overrides[rule.value.alert].labels, {})) + labels = merge(rule.value.labels, try(var.overrides[rule.value.alert].labels, {})) 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) @@ -58,7 +57,7 @@ resource "grafana_rule_group" "this" { to = 0 } datasource_uid = "__expr__" - model = jsonencode({ + model = jsonencode({ "conditions" = [ { "evaluator" = { @@ -100,7 +99,7 @@ resource "grafana_rule_group" "this" { to = 0 } datasource_uid = "__expr__" - model = jsonencode({ + model = jsonencode({ "conditions" = [ { "evaluator" = { diff --git a/locals.tf b/locals.tf index 0a03286..f770340 100644 --- a/locals.tf +++ b/locals.tf @@ -1,4 +1,4 @@ locals { file_as_yaml = yamldecode(var.prometheus_alerts_file_path) - alertsfile_map = {for group in local.file_as_yaml.groups: group.name => group} + alertsfile_map = { for group in local.file_as_yaml.groups : group.name => group } } diff --git a/variables.tf b/variables.tf index 25b4d50..5942c3a 100644 --- a/variables.tf +++ b/variables.tf @@ -28,18 +28,18 @@ variable "overrides" { variable "default_evaluation_interval_duration" { description = "How often is the rule evaluated by default. (When not defined inside your Alerting rules file)" - type = string - default = "5m" + type = string + default = "5m" } variable "org_id" { description = "The Organization ID of of the Grafana Alerting rule groups. (Only supported with basic auth, API keys are already org-scoped)" - type = string - default = null + type = string + default = null } variable "disable_provenance" { description = "Allow modifying the rule group from other sources than Terraform or the Grafana API." - type = bool - default = false + type = bool + default = false } diff --git a/versions.tf b/versions.tf index 28fd3d0..7cb80a8 100644 --- a/versions.tf +++ b/versions.tf @@ -1,7 +1,7 @@ terraform { required_providers { grafana = { - source = "grafana/grafana" + source = "grafana/grafana" version = "~> 3.2" } }