From 7c6d6f9438fb42b8eb2ea629f94225b69035d007 Mon Sep 17 00:00:00 2001 From: zjhe Date: Sat, 5 Oct 2024 10:43:31 +0800 Subject: [PATCH] add random suffix to resource group name --- quickstart/301-hub-spoke/hub-nva.tf | 8 +++++++- quickstart/301-hub-spoke/hub-vnet.tf | 2 +- quickstart/301-hub-spoke/main.tf | 2 +- quickstart/301-hub-spoke/on-prem.tf | 2 +- quickstart/301-hub-spoke/spoke1.tf | 2 +- quickstart/301-hub-spoke/spoke2.tf | 2 +- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/quickstart/301-hub-spoke/hub-nva.tf b/quickstart/301-hub-spoke/hub-nva.tf index dc9c492c..da6c907c 100644 --- a/quickstart/301-hub-spoke/hub-nva.tf +++ b/quickstart/301-hub-spoke/hub-nva.tf @@ -4,8 +4,14 @@ locals { hub-nva-resource-group = "hub-nva-rg" } +resource "random_string" "suffix" { + length = 5 + special = false + upper = false +} + resource "azurerm_resource_group" "hub-nva-rg" { - name = "${local.prefix-hub-nva}-rg" + name = "${local.prefix-hub-nva}-rg-${random_string.suffix.result}" location = local.hub-nva-location tags = { diff --git a/quickstart/301-hub-spoke/hub-vnet.tf b/quickstart/301-hub-spoke/hub-vnet.tf index fe9a4122..4e5878f8 100644 --- a/quickstart/301-hub-spoke/hub-vnet.tf +++ b/quickstart/301-hub-spoke/hub-vnet.tf @@ -1,7 +1,7 @@ locals { prefix-hub = "hub" hub-location = "eastus" - hub-resource-group = "hub-vnet-rg" + hub-resource-group = "hub-vnet-rg-${random_string.suffix.result}" shared-key = "4-v3ry-53cr37-1p53c-5h4r3d-k3y" } diff --git a/quickstart/301-hub-spoke/main.tf b/quickstart/301-hub-spoke/main.tf index 326eb963..6e54a38d 100644 --- a/quickstart/301-hub-spoke/main.tf +++ b/quickstart/301-hub-spoke/main.tf @@ -19,7 +19,7 @@ provider "azurerm" { } resource "random_password" "password" { - count = var.password == null ? 1 : 0 + count = var.password == null ? 1 : 0 length = 20 } diff --git a/quickstart/301-hub-spoke/on-prem.tf b/quickstart/301-hub-spoke/on-prem.tf index 4b9d98ee..4ec90fb2 100644 --- a/quickstart/301-hub-spoke/on-prem.tf +++ b/quickstart/301-hub-spoke/on-prem.tf @@ -1,6 +1,6 @@ locals { onprem-location = "eastus" - onprem-resource-group = "onprem-vnet-rg" + onprem-resource-group = "onprem-vnet-rg-${random_string.suffix.result}" prefix-onprem = "onprem" } diff --git a/quickstart/301-hub-spoke/spoke1.tf b/quickstart/301-hub-spoke/spoke1.tf index 44aa1998..4899ca4c 100644 --- a/quickstart/301-hub-spoke/spoke1.tf +++ b/quickstart/301-hub-spoke/spoke1.tf @@ -1,6 +1,6 @@ locals { spoke1-location = "eastus" - spoke1-resource-group = "spoke1-vnet-rg" + spoke1-resource-group = "spoke1-vnet-rg-${random_string.suffix.result}" prefix-spoke1 = "spoke1" } diff --git a/quickstart/301-hub-spoke/spoke2.tf b/quickstart/301-hub-spoke/spoke2.tf index 6f8eaf8a..e3fe6d87 100644 --- a/quickstart/301-hub-spoke/spoke2.tf +++ b/quickstart/301-hub-spoke/spoke2.tf @@ -1,6 +1,6 @@ locals { spoke2-location = "eastus" - spoke2-resource-group = "spoke2-vnet-rg" + spoke2-resource-group = "spoke2-vnet-rg-${random_string.suffix.result}" prefix-spoke2 = "spoke2" }