From c74ed38c2b5238daeea4908e72f01908eea5248b Mon Sep 17 00:00:00 2001 From: Arnaud Lheureux Date: Thu, 18 Mar 2021 03:09:18 +0000 Subject: [PATCH 1/2] Fix launchpad for count error --- landingzones/caf_launchpad/main.tf | 19 +++++++++---------- landingzones/caf_launchpad/variables.tf | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/landingzones/caf_launchpad/main.tf b/landingzones/caf_launchpad/main.tf index 27bf4e4d23..7064f4f8f7 100644 --- a/landingzones/caf_launchpad/main.tf +++ b/landingzones/caf_launchpad/main.tf @@ -6,7 +6,7 @@ terraform { } azuread = { source = "hashicorp/azuread" - version = "~> 1.0.0" + version = "~> 1.4.0" } random = { source = "hashicorp/random" @@ -41,8 +41,8 @@ provider "azurerm" { } } - resource "random_string" "prefix" { + count = var.prefix == null ? 1 : 0 length = 4 special = false upper = false @@ -50,6 +50,7 @@ resource "random_string" "prefix" { } resource "random_string" "alpha1" { + count = var.prefix == null ? 1 : 0 length = 1 special = false upper = false @@ -62,20 +63,18 @@ locals { } tags = merge(local.landingzone_tag, { "level" = var.landingzone.level }, { "environment" = var.environment }, { "rover_version" = var.rover_version }, var.tags) - prefix = var.prefix == null ? random_string.prefix.result : var.prefix - global_settings = { - prefix = local.prefix - prefix_with_hyphen = local.prefix == "" ? "" : "${local.prefix}-" - prefix_start_alpha = local.prefix == "" ? "" : "${random_string.alpha1.result}${local.prefix}" default_region = var.default_region environment = var.environment - regions = var.regions + inherit_tags = var.inherit_tags passthrough = var.passthrough + prefix = var.prefix + prefixes = var.prefix == "" ? null : [try(var.prefix, random_string.prefix.0.result)] + prefix_with_hyphen = var.prefix == "" ? "" : try(format("%s-", var.prefix) , format("%s-", random_string.prefix.0.result)) random_length = var.random_length - inherit_tags = var.inherit_tags - use_slug = var.use_slug + regions = var.regions tags = var.tags + use_slug = var.use_slug } tfstates = map( diff --git a/landingzones/caf_launchpad/variables.tf b/landingzones/caf_launchpad/variables.tf index 5d04bce8c6..c6b4a5c581 100644 --- a/landingzones/caf_launchpad/variables.tf +++ b/landingzones/caf_launchpad/variables.tf @@ -47,7 +47,7 @@ variable enable { } variable prefix { - default = null + default = "" } variable use_slug { From 63b52ffc578fd070c89228ceecb56998108977b4 Mon Sep 17 00:00:00 2001 From: Arnaud Lheureux Date: Fri, 19 Mar 2021 12:04:44 +0800 Subject: [PATCH 2/2] Update variables.tf --- landingzones/caf_launchpad/variables.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/landingzones/caf_launchpad/variables.tf b/landingzones/caf_launchpad/variables.tf index c6b4a5c581..acf69cd2f9 100644 --- a/landingzones/caf_launchpad/variables.tf +++ b/landingzones/caf_launchpad/variables.tf @@ -47,7 +47,7 @@ variable enable { } variable prefix { - default = "" + default = null } variable use_slug { @@ -188,4 +188,4 @@ variable azurerm_routes { variable keyvault_access_policies_azuread_apps { default = {} -} \ No newline at end of file +}