Skip to content

Commit 3042fe5

Browse files
fix: updated the default value of the prefix input to be "dev" in the DA.<br>- Marked the input as required in catalog so it will now show in the required tab of the projects UI.<br>- 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. (#270)
* update prefix logic * fix: error * resolve comment
1 parent 7f9b218 commit 3042fe5

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

ibm_catalog.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@
5151
"key": "watsonx_admin_api_key"
5252
},
5353
{
54-
"key": "prefix"
54+
"key": "prefix",
55+
"required": true,
56+
"description": "Prefix to add to all resources created by this solution. To not use any prefix value, you can enter the string `__NULL__`."
5557
},
5658
{
5759
"key": "use_existing_resource_group",

solutions/banking/main.tf

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ locals {
33
use_watson_machine_learning = (var.watson_machine_learning_instance_guid != null && var.watson_project_name != null) ? true : false
44
use_elastic_index = (var.elastic_instance_crn != null) ? true : false
55

6-
cos_instance_name = var.prefix != null ? "${var.prefix}-rag-sample-app-cos" : "gen-ai-rag-sample-app-cos"
7-
cos_kms_new_key_name = var.prefix != null ? "${var.prefix}-${var.cos_kms_new_key_name}" : var.cos_kms_new_key_name
6+
cos_instance_name = try("${local.prefix}-rag-sample-app-cos", "gen-ai-rag-sample-app-cos")
7+
cos_kms_new_key_name = try("${local.prefix}-${var.cos_kms_new_key_name}", var.cos_kms_new_key_name)
88
watsonx_assistant_url = "//api.${var.watson_assistant_region}.assistant.watson.cloud.ibm.com/instances/${var.watson_assistant_instance_id}"
99
watson_discovery_url = local.use_watson_discovery ? "//api.${var.watson_discovery_region}.discovery.watson.cloud.ibm.com/instances/${var.watson_discovery_instance_id}" : null
10-
watson_discovery_project_name = var.prefix != null ? "${var.prefix}-gen-ai-rag-sample-app-project" : "gen-ai-rag-sample-app-project"
11-
watson_discovery_collection_name = var.prefix != null ? "${var.prefix}-gen-ai-rag-sample-app-data" : "gen-ai-rag-sample-app-data"
12-
watson_ml_project_name = var.prefix != null ? "${var.prefix}-${var.watson_project_name}" : var.watson_project_name
10+
watson_discovery_project_name = try("${local.prefix}-gen-ai-rag-sample-app-project", "gen-ai-rag-sample-app-project")
11+
watson_discovery_collection_name = try("${local.prefix}-gen-ai-rag-sample-app-data", "gen-ai-rag-sample-app-data")
12+
watson_ml_project_name = try("${local.prefix}-${var.watson_project_name}", var.watson_project_name)
1313
sensitive_tokendata = sensitive(data.ibm_iam_auth_token.tokendata.iam_access_token)
1414

1515
# Translate index name to lowercase to avoid Elastic errors
16-
elastic_index_name = lower(var.prefix != null ? "${var.prefix}-${var.elastic_index_name}" : var.elastic_index_name)
16+
elastic_index_name = lower(try("${local.prefix}-${var.elastic_index_name}", var.elastic_index_name))
1717
elastic_credentials_data = local.use_elastic_index ? jsondecode(data.ibm_resource_key.elastic_credentials[0].credentials_json).connection.https : null
1818
# Compose the URL without credentials to keep the latter sensitive
1919
elastic_service_binding = local.use_elastic_index ? {
@@ -24,6 +24,8 @@ locals {
2424
} : null
2525

2626
cd_instance = var.create_continuous_delivery_service_instance ? ibm_resource_instance.cd_instance : null
27+
28+
prefix = var.prefix != null ? (var.prefix != "" ? var.prefix : null) : null
2729
}
2830

2931
data "ibm_iam_auth_token" "tokendata" {}
@@ -100,7 +102,7 @@ data "ibm_resource_group" "toolchain_resource_group_id" {
100102
resource "ibm_resource_instance" "cd_instance" {
101103
provider = ibm.ibm_resources
102104
count = var.create_continuous_delivery_service_instance ? 1 : 0
103-
name = "${var.prefix}-cd-instance"
105+
name = try("${local.prefix}-cd-instance", "cd-instance")
104106
service = "continuous-delivery"
105107
plan = "professional"
106108
location = var.toolchain_region

solutions/banking/variables.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ variable "watsonx_admin_api_key" {
2222
}
2323

2424
variable "prefix" {
25-
description = "Prefix for resources to be created"
25+
description = "The prefix to add to all resources that this solution creates. To not use any prefix value, you can set this value to `null` or an empty string."
2626
type = string
27+
default = "dev"
2728
}
2829

2930
variable "use_existing_resource_group" {

0 commit comments

Comments
 (0)