Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Apply terraform fmt #6

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions grafana_alert.tf
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -58,7 +57,7 @@ resource "grafana_rule_group" "this" {
to = 0
}
datasource_uid = "__expr__"
model = jsonencode({
model = jsonencode({
"conditions" = [
{
"evaluator" = {
Expand Down Expand Up @@ -100,7 +99,7 @@ resource "grafana_rule_group" "this" {
to = 0
}
datasource_uid = "__expr__"
model = jsonencode({
model = jsonencode({
"conditions" = [
{
"evaluator" = {
Expand Down
2 changes: 1 addition & 1 deletion locals.tf
Original file line number Diff line number Diff line change
@@ -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 }
}
12 changes: 6 additions & 6 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
grafana = {
source = "grafana/grafana"
source = "grafana/grafana"
version = "~> 3.2"
}
}
Expand Down
Loading