2026-03-25 06:38:06 +03:00
|
|
|
locals {
|
|
|
|
|
# Dashboards with both manual changes allowed and destroy protection
|
|
|
|
|
dashboards_ignore_and_protect = flatten([
|
|
|
|
|
for group in var.groups : [
|
|
|
|
|
for file in(group.dashboard_path_if_exist != null ? fileset(group.dashboard_path_if_exist, "**/*.json") : []) : {
|
|
|
|
|
group_name = group.dashboard_alert_group_name
|
|
|
|
|
file_path = "${group.dashboard_path_if_exist}/${file}"
|
|
|
|
|
dashboard_json = jsondecode(file("${group.dashboard_path_if_exist}/${file}"))
|
|
|
|
|
dashboard_uid = substr(
|
2026-03-25 08:54:43 +03:00
|
|
|
replace(
|
2026-03-25 06:38:06 +03:00
|
|
|
lower(
|
|
|
|
|
"${try(jsondecode(file("${group.dashboard_path_if_exist}/${file}")).uid, trimsuffix(basename(file), ".json"))}_${group.dashboard_path_if_exist}/${file}"
|
|
|
|
|
),
|
2026-03-25 08:54:43 +03:00
|
|
|
"/[^a-z0-9_-]/",
|
2026-03-25 06:38:06 +03:00
|
|
|
"_"
|
|
|
|
|
),
|
|
|
|
|
0,
|
|
|
|
|
var.dashboard_uid_max_length
|
|
|
|
|
)
|
|
|
|
|
folder_id = lookup(var.folder_ids, group.dashboard_alert_group_name, null)
|
|
|
|
|
keep_manual_changes = lookup(group, "keep_manual_changes", false)
|
|
|
|
|
prevent_destroy_on_recreate = lookup(group, "prevent_destroy_on_recreate", false)
|
|
|
|
|
}
|
|
|
|
|
] if lookup(group, "keep_manual_changes", false) && lookup(group, "prevent_destroy_on_recreate", false)
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
# Dashboards with only manual changes allowed
|
|
|
|
|
dashboards_ignore_only = flatten([
|
|
|
|
|
for group in var.groups : [
|
|
|
|
|
for file in(group.dashboard_path_if_exist != null ? fileset(group.dashboard_path_if_exist, "**/*.json") : []) : {
|
|
|
|
|
group_name = group.dashboard_alert_group_name
|
|
|
|
|
file_path = "${group.dashboard_path_if_exist}/${file}"
|
|
|
|
|
dashboard_json = jsondecode(file("${group.dashboard_path_if_exist}/${file}"))
|
|
|
|
|
dashboard_uid = substr(
|
2026-03-25 08:54:43 +03:00
|
|
|
replace(
|
2026-03-25 06:38:06 +03:00
|
|
|
lower(
|
|
|
|
|
"${try(jsondecode(file("${group.dashboard_path_if_exist}/${file}")).uid, trimsuffix(basename(file), ".json"))}_${group.dashboard_path_if_exist}/${file}"
|
|
|
|
|
),
|
2026-03-25 08:54:43 +03:00
|
|
|
"/[^a-z0-9_-]/",
|
2026-03-25 06:38:06 +03:00
|
|
|
"_"
|
|
|
|
|
),
|
|
|
|
|
0,
|
|
|
|
|
var.dashboard_uid_max_length
|
|
|
|
|
)
|
|
|
|
|
folder_id = lookup(var.folder_ids, group.dashboard_alert_group_name, null)
|
|
|
|
|
keep_manual_changes = lookup(group, "keep_manual_changes", false)
|
|
|
|
|
prevent_destroy_on_recreate = lookup(group, "prevent_destroy_on_recreate", false)
|
|
|
|
|
}
|
|
|
|
|
] if lookup(group, "keep_manual_changes", false) && !lookup(group, "prevent_destroy_on_recreate", false)
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
# Dashboards with only destroy protection
|
|
|
|
|
dashboards_protect_only = flatten([
|
|
|
|
|
for group in var.groups : [
|
|
|
|
|
for file in(group.dashboard_path_if_exist != null ? fileset(group.dashboard_path_if_exist, "**/*.json") : []) : {
|
|
|
|
|
group_name = group.dashboard_alert_group_name
|
|
|
|
|
file_path = "${group.dashboard_path_if_exist}/${file}"
|
|
|
|
|
dashboard_json = jsondecode(file("${group.dashboard_path_if_exist}/${file}"))
|
|
|
|
|
dashboard_uid = substr(
|
2026-03-25 08:54:43 +03:00
|
|
|
replace(
|
2026-03-25 06:38:06 +03:00
|
|
|
lower(
|
|
|
|
|
"${try(jsondecode(file("${group.dashboard_path_if_exist}/${file}")).uid, trimsuffix(basename(file), ".json"))}_${group.dashboard_path_if_exist}/${file}"
|
|
|
|
|
),
|
2026-03-25 08:54:43 +03:00
|
|
|
"/[^a-z0-9_-]/",
|
2026-03-25 06:38:06 +03:00
|
|
|
"_"
|
|
|
|
|
),
|
|
|
|
|
0,
|
|
|
|
|
var.dashboard_uid_max_length
|
|
|
|
|
)
|
|
|
|
|
folder_id = lookup(var.folder_ids, group.dashboard_alert_group_name, null)
|
|
|
|
|
keep_manual_changes = lookup(group, "keep_manual_changes", false)
|
|
|
|
|
prevent_destroy_on_recreate = lookup(group, "prevent_destroy_on_recreate", false)
|
|
|
|
|
}
|
|
|
|
|
] if !lookup(group, "keep_manual_changes", false) && lookup(group, "prevent_destroy_on_recreate", false)
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
# Standard dashboards without any special lifecycle management
|
|
|
|
|
dashboards_standard = flatten([
|
|
|
|
|
for group in var.groups : [
|
|
|
|
|
for file in(group.dashboard_path_if_exist != null ? fileset(group.dashboard_path_if_exist, "**/*.json") : []) : {
|
|
|
|
|
group_name = group.dashboard_alert_group_name
|
|
|
|
|
file_path = "${group.dashboard_path_if_exist}/${file}"
|
|
|
|
|
dashboard_json = jsondecode(file("${group.dashboard_path_if_exist}/${file}"))
|
|
|
|
|
dashboard_uid = substr(
|
2026-03-25 08:54:43 +03:00
|
|
|
replace(
|
2026-03-25 06:38:06 +03:00
|
|
|
lower(
|
|
|
|
|
"${try(jsondecode(file("${group.dashboard_path_if_exist}/${file}")).uid, trimsuffix(basename(file), ".json"))}_${group.dashboard_path_if_exist}/${file}"
|
|
|
|
|
),
|
2026-03-25 08:54:43 +03:00
|
|
|
"/[^a-z0-9_-]/",
|
2026-03-25 06:38:06 +03:00
|
|
|
"_"
|
|
|
|
|
),
|
|
|
|
|
0,
|
|
|
|
|
var.dashboard_uid_max_length
|
|
|
|
|
)
|
|
|
|
|
folder_id = lookup(var.folder_ids, group.dashboard_alert_group_name, null)
|
|
|
|
|
keep_manual_changes = lookup(group, "keep_manual_changes", false)
|
|
|
|
|
prevent_destroy_on_recreate = lookup(group, "prevent_destroy_on_recreate", false)
|
|
|
|
|
}
|
|
|
|
|
] if !lookup(group, "keep_manual_changes", false) && !lookup(group, "prevent_destroy_on_recreate", false)
|
|
|
|
|
])
|
|
|
|
|
}
|