From 7b83b84460c3159730358c347a9402ed784b276e Mon Sep 17 00:00:00 2001 From: Alexandr Date: Wed, 25 Mar 2026 08:54:43 +0300 Subject: [PATCH] Fix dashboard UID sanitization for Terraform by replacing regexreplace --- environments/modules/grafana_dashboard/locals.tf | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/environments/modules/grafana_dashboard/locals.tf b/environments/modules/grafana_dashboard/locals.tf index d980d1e..7fd79c1 100644 --- a/environments/modules/grafana_dashboard/locals.tf +++ b/environments/modules/grafana_dashboard/locals.tf @@ -7,11 +7,11 @@ locals { file_path = "${group.dashboard_path_if_exist}/${file}" dashboard_json = jsondecode(file("${group.dashboard_path_if_exist}/${file}")) dashboard_uid = substr( - regexreplace( + replace( lower( "${try(jsondecode(file("${group.dashboard_path_if_exist}/${file}")).uid, trimsuffix(basename(file), ".json"))}_${group.dashboard_path_if_exist}/${file}" ), - "[^a-z0-9_-]", + "/[^a-z0-9_-]/", "_" ), 0, @@ -32,11 +32,11 @@ locals { file_path = "${group.dashboard_path_if_exist}/${file}" dashboard_json = jsondecode(file("${group.dashboard_path_if_exist}/${file}")) dashboard_uid = substr( - regexreplace( + replace( lower( "${try(jsondecode(file("${group.dashboard_path_if_exist}/${file}")).uid, trimsuffix(basename(file), ".json"))}_${group.dashboard_path_if_exist}/${file}" ), - "[^a-z0-9_-]", + "/[^a-z0-9_-]/", "_" ), 0, @@ -57,11 +57,11 @@ locals { file_path = "${group.dashboard_path_if_exist}/${file}" dashboard_json = jsondecode(file("${group.dashboard_path_if_exist}/${file}")) dashboard_uid = substr( - regexreplace( + replace( lower( "${try(jsondecode(file("${group.dashboard_path_if_exist}/${file}")).uid, trimsuffix(basename(file), ".json"))}_${group.dashboard_path_if_exist}/${file}" ), - "[^a-z0-9_-]", + "/[^a-z0-9_-]/", "_" ), 0, @@ -82,11 +82,11 @@ locals { file_path = "${group.dashboard_path_if_exist}/${file}" dashboard_json = jsondecode(file("${group.dashboard_path_if_exist}/${file}")) dashboard_uid = substr( - regexreplace( + replace( lower( "${try(jsondecode(file("${group.dashboard_path_if_exist}/${file}")).uid, trimsuffix(basename(file), ".json"))}_${group.dashboard_path_if_exist}/${file}" ), - "[^a-z0-9_-]", + "/[^a-z0-9_-]/", "_" ), 0,