Skip to content

Commit 51a6d7e

Browse files
fix: updated the default value of the prefix input to be "dev". Marked the input as required in catalog so it will now show in the required tab of the projects UI. It is still possible omit the prefix by passing a value of null or empty string ("") when working directly with the terraform code, or by passing the string value of __NULL__ when deploying in projects or schematics. (#388)
1 parent 2a6213e commit 51a6d7e

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

ibm_catalog.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@
117117
"key": "resource_group_name"
118118
},
119119
{
120-
"key": "prefix"
120+
"key": "prefix",
121+
"required": true,
122+
"description": "Prefix to add to all resources created by this solution. To not use any prefix value, you can enter the string `__NULL__`."
121123
},
122124
{
123125
"key": "region",

solutions/standard/main.tf

Lines changed: 8 additions & 8 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.existing_db_instance_crn == null && !var.use_ibm_owned_encryption_key && var.existing_kms_key_crn == null ? 1 : 0 # no need to create any KMS resources if using existing Elasticsearch, passing an existing key, or using IBM owned keys
32-
elasticsearch_key_name = var.prefix != null ? "${var.prefix}-${var.elasticsearch_key_name}" : var.elasticsearch_key_name
33-
elasticsearch_key_ring_name = var.prefix != null ? "${var.prefix}-${var.elasticsearch_key_ring_name}" : var.elasticsearch_key_ring_name
32+
elasticsearch_key_name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-${var.elasticsearch_key_name}" : var.elasticsearch_key_name
33+
elasticsearch_key_ring_name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-${var.elasticsearch_key_ring_name}" : var.elasticsearch_key_ring_name
3434
}
3535

3636
module "kms" {
@@ -292,7 +292,7 @@ module "elasticsearch" {
292292
source = "../../modules/fscloud"
293293
depends_on = [time_sleep.wait_for_authorization_policy, time_sleep.wait_for_backup_kms_authorization_policy]
294294
resource_group_id = module.resource_group.resource_group_id
295-
name = var.prefix != null ? "${var.prefix}-${var.name}" : var.name
295+
name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-${var.name}" : var.name
296296
region = var.region
297297
plan = var.plan
298298
skip_iam_authorization_policy = var.skip_es_kms_auth_policy
@@ -398,10 +398,10 @@ locals {
398398

399399
# Build the structure of the arbitrary credential type secret for admin password
400400
admin_pass_secret = [{
401-
secret_group_name = var.prefix != null && var.admin_pass_sm_secret_group != null ? "${var.prefix}-${var.admin_pass_sm_secret_group}" : var.admin_pass_sm_secret_group
401+
secret_group_name = (var.prefix != null && var.prefix != "") && var.admin_pass_sm_secret_group != null ? "${var.prefix}-${var.admin_pass_sm_secret_group}" : var.admin_pass_sm_secret_group
402402
existing_secret_group = var.use_existing_admin_pass_sm_secret_group
403403
secrets = [{
404-
secret_name = var.prefix != null && var.admin_pass_sm_secret_name != null ? "${var.prefix}-${var.admin_pass_sm_secret_name}" : var.admin_pass_sm_secret_name
404+
secret_name = (var.prefix != null && var.prefix != "") && var.admin_pass_sm_secret_name != null ? "${var.prefix}-${var.admin_pass_sm_secret_name}" : var.admin_pass_sm_secret_name
405405
secret_type = "arbitrary"
406406
secret_payload_password = local.admin_pass
407407
}
@@ -433,8 +433,8 @@ module "secrets_manager_service_credentials" {
433433

434434
locals {
435435
code_engine_project_id = var.existing_code_engine_project_id != null ? var.existing_code_engine_project_id : null
436-
code_engine_project_name = local.code_engine_project_id != null ? null : var.prefix != null ? "${var.prefix}-code-engine-kibana-project" : "ce-kibana-project"
437-
code_engine_app_name = var.prefix != null ? "${var.prefix}-kibana-app" : "ce-kibana-app"
436+
code_engine_project_name = local.code_engine_project_id != null ? null : (var.prefix != null && var.prefix != "") ? "${var.prefix}-code-engine-kibana-project" : "ce-kibana-project"
437+
code_engine_app_name = (var.prefix != null && var.prefix != "") ? "${var.prefix}-kibana-app" : "ce-kibana-app"
438438
kibana_version = var.enable_kibana_dashboard ? jsondecode(data.http.es_metadata[0].response_body).version.number : null
439439
}
440440

solutions/standard/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ variable "provider_visibility" {
2121

2222
variable "prefix" {
2323
type = string
24-
description = "Prefix to add to all resources created by this solution."
25-
default = null
24+
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."
25+
default = "dev"
2626
}
2727

2828
##############################################################################

0 commit comments

Comments
 (0)