Skip to content
This repository was archived by the owner on Mar 19, 2025. It is now read-only.

Commit 4160c67

Browse files
aatreyee2506Aatreyee Mukherjee
andauthored
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. (#246)
Co-authored-by: Aatreyee Mukherjee <[email protected]>
1 parent 3507ada commit 4160c67

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

ibm_catalog.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@
8484
"key": "resource_group_name"
8585
},
8686
{
87-
"key": "prefix"
87+
"key": "prefix",
88+
"required": true,
89+
"description": "The prefix to add to all resources that this solution creates. To not use any prefix value, you can enter the string `__NULL__`."
8890
},
8991
{
9092
"key": "existing_monitoring_crn"

solutions/instances/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ This solution supports provisioning and configuring the following infrastructure
7575
| <a name="input_ibmcloud_kms_api_key"></a> [ibmcloud\_kms\_api\_key](#input\_ibmcloud\_kms\_api\_key) | The IBM Cloud API key that can create a root key and key ring in the key management service (KMS) instance. If not specified, the 'ibmcloud\_api\_key' variable is used. Specify this key if the instance in `existing_kms_instance_crn` is in an account that's different from the Security and Compliance Centre instance. Leave this input empty if the same account owns both instances. | `string` | `null` | no |
7676
| <a name="input_kms_endpoint_type"></a> [kms\_endpoint\_type](#input\_kms\_endpoint\_type) | The endpoint for communicating with the KMS instance. Possible values: `public`, `private.` | `string` | `"private"` | no |
7777
| <a name="input_management_endpoint_type_for_bucket"></a> [management\_endpoint\_type\_for\_bucket](#input\_management\_endpoint\_type\_for\_bucket) | The type of endpoint for the IBM Terraform provider to use to manage Object Storage buckets. Possible values: `public`, `private`m `direct`. If you specify `private`, enable virtual routing and forwarding in your account, and the Terraform runtime must have access to the the IBM Cloud private network. | `string` | `"private"` | no |
78-
| <a name="input_prefix"></a> [prefix](#input\_prefix) | The prefix to add to all resources created by this solution. | `string` | `null` | no |
78+
| <a name="input_prefix"></a> [prefix](#input\_prefix) | 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. | `string` | `"dev"` | no |
7979
| <a name="input_profile_attachments"></a> [profile\_attachments](#input\_profile\_attachments) | The list of Security and Compliance Center profile attachments to create that are scoped to your IBM Cloud account. The attachment schedule runs daily and defaults to the latest version of the specified profile attachments. | `list(string)` | <pre>[<br/> "IBM Cloud Framework for Financial Services"<br/>]</pre> | no |
8080
| <a name="input_provider_visibility"></a> [provider\_visibility](#input\_provider\_visibility) | Set the visibility value for the IBM terraform provider. Supported values are `public`, `private`, `public-and-private`. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/guides/custom-service-endpoints). | `string` | `"private"` | no |
8181
| <a name="input_provision_scc_workload_protection"></a> [provision\_scc\_workload\_protection](#input\_provision\_scc\_workload\_protection) | Whether to provision a Workload Protection instance. | `bool` | `true` | no |

solutions/instances/main.tf

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ locals {
2020
module "resource_group" {
2121
source = "terraform-ibm-modules/resource-group/ibm"
2222
version = "1.1.6"
23-
resource_group_name = var.use_existing_resource_group == false ? (var.prefix != null ? "${var.prefix}-${var.resource_group_name}" : var.resource_group_name) : null
23+
resource_group_name = var.use_existing_resource_group == false ? try("${local.prefix}-${var.resource_group_name}", var.resource_group_name) : null
2424
existing_resource_group_name = var.use_existing_resource_group == true ? var.resource_group_name : null
2525
}
2626

@@ -49,13 +49,16 @@ locals {
4949
kms_account_id = var.existing_kms_instance_crn != null ? module.existing_kms_crn_parser[0].account_id : null
5050
kms_key_id = var.existing_scc_instance_crn == null && length(module.existing_kms_key_crn_parser) > 0 ? module.existing_kms_key_crn_parser[0].resource : null
5151

52-
scc_cos_key_ring_name = var.prefix != null ? "${var.prefix}-${var.scc_cos_key_ring_name}" : var.scc_cos_key_ring_name
53-
scc_cos_key_name = var.prefix != null ? "${var.prefix}-${var.scc_cos_key_name}" : var.scc_cos_key_name
54-
cos_instance_name = var.prefix != null ? "${var.prefix}-${var.cos_instance_name}" : var.cos_instance_name
55-
scc_instance_name = var.prefix != null ? "${var.prefix}-${var.scc_instance_name}" : var.scc_instance_name
56-
scc_workload_protection_instance_name = var.prefix != null ? "${var.prefix}-${var.scc_workload_protection_instance_name}" : var.scc_workload_protection_instance_name
57-
scc_workload_protection_resource_key_name = var.prefix != null ? "${var.prefix}-${var.scc_workload_protection_instance_name}-key" : "${var.scc_workload_protection_instance_name}-key"
58-
scc_cos_bucket_name = var.prefix != null ? "${var.prefix}-${var.scc_cos_bucket_name}" : var.scc_cos_bucket_name
52+
prefix = var.prefix != null ? (var.prefix != "" ? var.prefix : null) : null
53+
54+
55+
scc_cos_key_ring_name = try("${local.prefix}-${var.scc_cos_key_ring_name}", var.scc_cos_key_ring_name)
56+
scc_cos_key_name = try("${local.prefix}-${var.scc_cos_key_name}", var.scc_cos_key_name)
57+
cos_instance_name = try("${local.prefix}-${var.cos_instance_name}", var.cos_instance_name)
58+
scc_instance_name = try("${local.prefix}-${var.scc_instance_name}", var.scc_instance_name)
59+
scc_workload_protection_instance_name = try("${local.prefix}-${var.scc_workload_protection_instance_name}", var.scc_workload_protection_instance_name)
60+
scc_workload_protection_resource_key_name = try("${local.prefix}-${var.scc_workload_protection_instance_name}-key", "${var.scc_workload_protection_instance_name}-key")
61+
scc_cos_bucket_name = try("${local.prefix}-${var.scc_cos_bucket_name}", var.scc_cos_bucket_name)
5962

6063
create_cross_account_auth_policy = !var.skip_cos_kms_auth_policy && var.ibmcloud_kms_api_key == null ? false : (data.ibm_iam_account_settings.iam_account_settings.account_id != module.existing_kms_crn_parser[0].account_id)
6164
}
@@ -347,9 +350,9 @@ module "existing_en_crn_parser" {
347350

348351
locals {
349352
existing_en_guid = var.existing_en_crn != null ? module.existing_en_crn_parser[0].service_instance : null
350-
en_topic = var.prefix != null ? "${var.prefix} - SCC Topic" : "SCC Topic"
353+
en_topic = try("${local.prefix}-SCC Topic", "SCC Topic")
351354
existing_en_region = var.existing_en_crn != null ? module.existing_en_crn_parser[0].region : null
352-
en_subscription_email = var.prefix != null ? "${var.prefix} - Email for Security and Compliance Center Subscription" : "Email for Security and Compliance Center Subscription"
355+
en_subscription_email = try("${local.prefix}-Email for Security and Compliance Center Subscription", "Email for Security and Compliance Center Subscription")
353356
}
354357

355358
data "ibm_en_destinations" "en_destinations" {

solutions/instances/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ variable "existing_monitoring_crn" {
2828

2929
variable "prefix" {
3030
type = string
31-
description = "The prefix to add to all resources created by this solution."
32-
default = null
31+
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."
32+
default = "dev"
3333
}
3434

3535
variable "provider_visibility" {

0 commit comments

Comments
 (0)