Skip to content

Commit 1cc3131

Browse files
arya-girish-kArya Girish K
andauthored
fix: update code to accept prefix as empty string ("") and mark as required in catalog manifest (#565)
* refactor:update the prefix logic in DA * update prefix value * SKIP UPGRADE TEST * changed the description --------- Co-authored-by: Arya Girish K <arya.girish.k@ibm.com>
1 parent bf157c6 commit 1cc3131

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

ibm_catalog.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@
128128
"key": "resource_group_name"
129129
},
130130
{
131-
"key": "prefix"
131+
"key": "prefix",
132+
"required": true,
133+
"description":"Prefix to add to all resources created by this solution. To not use any prefix value, you can enter the string `__NULL__`."
132134
},
133135
{
134136
"key": "name"

solutions/standard/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
module "resource_group" {
66
source = "terraform-ibm-modules/resource-group/ibm"
77
version = "1.1.6"
8-
resource_group_name = var.use_existing_resource_group == false ? (var.prefix != null ? "${var.prefix}-${var.resource_group_name}" : var.resource_group_name) : null
8+
resource_group_name = var.use_existing_resource_group == false ? ((var.prefix != null && var.prefix != "") ? "${var.prefix}-${var.resource_group_name}" : var.resource_group_name) : null
99
existing_resource_group_name = var.use_existing_resource_group == true ? var.resource_group_name : null
1010
}
1111

@@ -29,8 +29,8 @@ locals {
2929

3030
locals {
3131
create_new_kms_key = !var.use_ibm_owned_encryption_key && var.existing_kms_key_crn == null ? true : false # no need to create any KMS resources if passing an existing key, or using IBM owned keys
32-
postgres_key_name = var.prefix != null ? "${var.prefix}-${var.key_name}" : var.key_name
33-
postgres_key_ring_name = var.prefix != null ? "${var.prefix}-${var.key_ring_name}" : var.key_ring_name
32+
postgres_key_name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-${var.key_name}" : var.key_name
33+
postgres_key_ring_name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-${var.key_ring_name}" : var.key_ring_name
3434
}
3535

3636
module "kms" {
@@ -246,7 +246,7 @@ module "postgresql_db" {
246246
source = "../../modules/fscloud"
247247
depends_on = [time_sleep.wait_for_authorization_policy, time_sleep.wait_for_backup_kms_authorization_policy]
248248
resource_group_id = module.resource_group.resource_group_id
249-
name = var.prefix != null ? "${var.prefix}-${var.name}" : var.name
249+
name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-${var.name}" : var.name
250250
region = var.region
251251
remote_leader_crn = var.remote_leader_crn
252252
skip_iam_authorization_policy = var.skip_pg_kms_auth_policy

solutions/standard/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ variable "resource_group_name" {
3232

3333
variable "prefix" {
3434
type = string
35-
description = "Prefix to add to all resources created by this solution."
36-
default = null
35+
description = "Prefix to add to all resources created by this solution. To not use any prefix value, you can set this value to `null` or an empty string."
36+
default = "postgresql"
3737
}
3838

3939
variable "name" {

0 commit comments

Comments
 (0)