53 lines
1.6 KiB
Terraform
53 lines
1.6 KiB
Terraform
|
|
# 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
|
||
|
|
}
|