From c4d0c49e0445ad68c328996314c97dccabb15de2 Mon Sep 17 00:00:00 2001 From: Arya Girish K Date: Fri, 20 Dec 2024 19:03:13 +0530 Subject: [PATCH 1/4] refactor:Add default value for prefix and mark as required in catalog.json --- ibm_catalog.json | 3 ++- solutions/account-infrastructure-base/variables.tf | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ibm_catalog.json b/ibm_catalog.json index 2517016..7579951 100644 --- a/ibm_catalog.json +++ b/ibm_catalog.json @@ -116,7 +116,8 @@ ] }, { - "key": "prefix" + "key": "prefix", + "required": true }, { "key": "skip_iam_account_settings" diff --git a/solutions/account-infrastructure-base/variables.tf b/solutions/account-infrastructure-base/variables.tf index 025c788..dd0a209 100644 --- a/solutions/account-infrastructure-base/variables.tf +++ b/solutions/account-infrastructure-base/variables.tf @@ -27,13 +27,13 @@ variable "region" { variable "prefix" { type = string description = "An optional prefix to append to all resources created by this solution. If `provision_atracker_cos` is true, this value will be converted to lowercase in all instances." - default = null + default = "acc-infra-base" # prefix restriction due to limitations when using multiple DAs in stacks # this value was determined based on the lowest prefix restriction located here: # https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone/blob/main/patterns/roks/variables.tf#L11 validation { - condition = var.prefix == null || can(length(var.prefix)) && length(var.prefix) <= 13 + condition = var.prefix == null || var.prefix == "" || can(length(var.prefix)) && length(var.prefix) <= 13 error_message = "`prefix` length must be 13 characters or less or null." } } From ad4de41c2dc8bf403b4324e485208a6786958fcd Mon Sep 17 00:00:00 2001 From: Arya Girish K Date: Mon, 23 Dec 2024 12:09:52 +0530 Subject: [PATCH 2/4] updated the branch --- common-dev-assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common-dev-assets b/common-dev-assets index d63f9de..5cf7d9c 160000 --- a/common-dev-assets +++ b/common-dev-assets @@ -1 +1 @@ -Subproject commit d63f9deaba4c5f17d1002b281f68ab36b42b0344 +Subproject commit 5cf7d9c5c426495cab1abd4e367416a2562edc2d From e3e54f73dcbd9cf40e29d2e09a573087879294df Mon Sep 17 00:00:00 2001 From: Arya Girish K Date: Fri, 3 Jan 2025 15:18:28 +0530 Subject: [PATCH 3/4] modified prefix logic --- solutions/account-infrastructure-base/main.tf | 2 +- solutions/account-infrastructure-base/variables.tf | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/solutions/account-infrastructure-base/main.tf b/solutions/account-infrastructure-base/main.tf index 3977eac..b02a24f 100644 --- a/solutions/account-infrastructure-base/main.tf +++ b/solutions/account-infrastructure-base/main.tf @@ -184,7 +184,7 @@ module "account_infrastructure_base" { provision_atracker_cos = var.provision_atracker_cos skip_cos_kms_auth_policy = var.skip_cos_kms_auth_policy cos_instance_name = !var.provision_atracker_cos ? null : (var.cos_instance_name == null ? try("${local.prefix}-cos-instance", "cos-instance") : var.cos_instance_name) - cos_bucket_name = !var.provision_atracker_cos ? null : (var.cos_bucket_name == null ? try("${local.prefix}-cos-bucket", "cos-bucket") : lower(var.cos_bucket_name)) + cos_bucket_name = !var.provision_atracker_cos ? null : (var.cos_bucket_name == null ? try("${trimprefix(local.prefix, "-")}-cos-bucket", "cos-bucket") : lower(var.cos_bucket_name)) cos_target_name = !var.provision_atracker_cos ? null : (var.cos_target_name == null ? try("${local.prefix}-cos-target", "cos-target") : var.cos_target_name) activity_tracker_route_name = var.activity_tracker_route_name == null ? try("${local.prefix}-cos-route", "cos-route") : var.activity_tracker_route_name cos_bucket_management_endpoint_type = var.cos_bucket_management_endpoint_type diff --git a/solutions/account-infrastructure-base/variables.tf b/solutions/account-infrastructure-base/variables.tf index dd0a209..1ea4224 100644 --- a/solutions/account-infrastructure-base/variables.tf +++ b/solutions/account-infrastructure-base/variables.tf @@ -26,15 +26,15 @@ variable "region" { variable "prefix" { type = string - description = "An optional prefix to append to all resources created by this solution. If `provision_atracker_cos` is true, this value will be converted to lowercase in all instances." - default = "acc-infra-base" + description = "An optional prefix to append to all resources created by this solution. If `provision_atracker_cos` is true, this value will be converted to lowercase in all instances. Prefix value can be an empty string (\"\") or `null` for advanced users." + default = "accinfbase" # prefix restriction due to limitations when using multiple DAs in stacks # this value was determined based on the lowest prefix restriction located here: # https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone/blob/main/patterns/roks/variables.tf#L11 validation { - condition = var.prefix == null || var.prefix == "" || can(length(var.prefix)) && length(var.prefix) <= 13 - error_message = "`prefix` length must be 13 characters or less or null." + condition = (var.prefix == null || var.prefix == "") ? true : length(var.prefix) <= 13 + error_message = "prefix` length must be 13 characters or less or null or an empty string (\"\")." } } From ca9d45bcccb59f27b8bcdd68594ab5f2f3be8c8e Mon Sep 17 00:00:00 2001 From: Arya Girish K Date: Wed, 8 Jan 2025 09:56:14 +0530 Subject: [PATCH 4/4] Modified the Prefix variable --- solutions/account-infrastructure-base/main.tf | 4 ++-- solutions/account-infrastructure-base/variables.tf | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/solutions/account-infrastructure-base/main.tf b/solutions/account-infrastructure-base/main.tf index b02a24f..5b372fb 100644 --- a/solutions/account-infrastructure-base/main.tf +++ b/solutions/account-infrastructure-base/main.tf @@ -3,7 +3,7 @@ ######################################################################################################################## locals { - prefix = var.provision_atracker_cos ? lower(var.prefix) : var.prefix + prefix = var.provision_atracker_cos ? (var.prefix != null && var.prefix != "" ? lower(var.prefix) : null) : var.prefix target_service_details = { "IAM" = { enforcement_mode = var.cbr_enforcement_mode @@ -184,7 +184,7 @@ module "account_infrastructure_base" { provision_atracker_cos = var.provision_atracker_cos skip_cos_kms_auth_policy = var.skip_cos_kms_auth_policy cos_instance_name = !var.provision_atracker_cos ? null : (var.cos_instance_name == null ? try("${local.prefix}-cos-instance", "cos-instance") : var.cos_instance_name) - cos_bucket_name = !var.provision_atracker_cos ? null : (var.cos_bucket_name == null ? try("${trimprefix(local.prefix, "-")}-cos-bucket", "cos-bucket") : lower(var.cos_bucket_name)) + cos_bucket_name = !var.provision_atracker_cos ? null : (var.cos_bucket_name == null ? try("${local.prefix}-cos-bucket", "cos-bucket") : lower(var.cos_bucket_name)) cos_target_name = !var.provision_atracker_cos ? null : (var.cos_target_name == null ? try("${local.prefix}-cos-target", "cos-target") : var.cos_target_name) activity_tracker_route_name = var.activity_tracker_route_name == null ? try("${local.prefix}-cos-route", "cos-route") : var.activity_tracker_route_name cos_bucket_management_endpoint_type = var.cos_bucket_management_endpoint_type diff --git a/solutions/account-infrastructure-base/variables.tf b/solutions/account-infrastructure-base/variables.tf index 1ea4224..57b465b 100644 --- a/solutions/account-infrastructure-base/variables.tf +++ b/solutions/account-infrastructure-base/variables.tf @@ -27,7 +27,7 @@ variable "region" { variable "prefix" { type = string description = "An optional prefix to append to all resources created by this solution. If `provision_atracker_cos` is true, this value will be converted to lowercase in all instances. Prefix value can be an empty string (\"\") or `null` for advanced users." - default = "accinfbase" + default = "infrabase" # prefix restriction due to limitations when using multiple DAs in stacks # this value was determined based on the lowest prefix restriction located here: