Add dashboard UID auto-generation and Gitea dev workflow

This commit is contained in:
Alexandr
2026-03-25 06:38:06 +03:00
commit 345c5786b3
11 changed files with 802 additions and 0 deletions

View File

@ -0,0 +1,52 @@
# Dashboards with both manual changes allowed and destroy protection
resource "grafana_dashboard" "dashboards_ignore_and_protect" {
for_each = { for d in local.dashboards_ignore_and_protect : d.file_path => d }
config_json = jsonencode(merge(each.value.dashboard_json, { uid = each.value.dashboard_uid }))
folder = each.value.folder_id
org_id = var.org_id
overwrite = true
lifecycle {
prevent_destroy = true
ignore_changes = [config_json]
}
}
# Dashboards with only manual changes allowed
resource "grafana_dashboard" "dashboards_ignore_only" {
for_each = { for d in local.dashboards_ignore_only : d.file_path => d }
config_json = jsonencode(merge(each.value.dashboard_json, { uid = each.value.dashboard_uid }))
folder = each.value.folder_id
org_id = var.org_id
overwrite = true
lifecycle {
ignore_changes = [config_json]
}
}
# Dashboards with only destroy protection
resource "grafana_dashboard" "dashboards_protect_only" {
for_each = { for d in local.dashboards_protect_only : d.file_path => d }
config_json = jsonencode(merge(each.value.dashboard_json, { uid = each.value.dashboard_uid }))
folder = each.value.folder_id
org_id = var.org_id
overwrite = true
lifecycle {
prevent_destroy = true
}
}
# Standard dashboards without any special lifecycle management
resource "grafana_dashboard" "dashboards_standard" {
for_each = { for d in local.dashboards_standard : d.file_path => d }
config_json = jsonencode(merge(each.value.dashboard_json, { uid = each.value.dashboard_uid }))
folder = each.value.folder_id
org_id = var.org_id
overwrite = true
}