From fce1d5069e2436ad30f56645bc20f17a84b1796a Mon Sep 17 00:00:00 2001 From: matteopasa <146732818+matteopasa@users.noreply.github.com> Date: Tue, 9 Jan 2024 09:44:16 +0100 Subject: [PATCH] Add subscription id hash to event hub namespace name (#24) --- modules/services/event-hub-data-source/main.tf | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/services/event-hub-data-source/main.tf b/modules/services/event-hub-data-source/main.tf index 669fb0a..1efc566 100644 --- a/modules/services/event-hub-data-source/main.tf +++ b/modules/services/event-hub-data-source/main.tf @@ -5,6 +5,11 @@ data "azurerm_subscription" "sysdig_subscription" { subscription_id = var.subscription_id } +# Generate a unique hash for the subscription ID +locals { + subscription_hash = substr(md5(data.azurerm_client_config.current.subscription_id), 0, 8) +} + #--------------------------------------------------------------------------------------------- # Create service principal in customer tenant #--------------------------------------------------------------------------------------------- @@ -28,7 +33,7 @@ resource "azurerm_resource_group" "sysdig_resource_group" { # Create an Event Hub Namespace for Sysdig #--------------------------------------------------------------------------------------------- resource "azurerm_eventhub_namespace" "sysdig_event_hub_namespace" { - name = var.event_hub_namespace_name + name = "${var.event_hub_namespace_name}-${local.subscription_hash}" location = azurerm_resource_group.sysdig_resource_group.location resource_group_name = azurerm_resource_group.sysdig_resource_group.name sku = var.namespace_sku