Skip to content

Commit 8d7f1f9

Browse files
committed
fix variable descriptions, add bucket suffix
1 parent dcf9464 commit 8d7f1f9

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

ibm_catalog.json

+3
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,9 @@
529529
{
530530
"key": "cos_bucket_name"
531531
},
532+
{
533+
"key": "add_bucket_name_suffix"
534+
},
532535
{
533536
"key": "kms_encryption_enabled_bucket"
534537
},

solutions/fully-configurable/main.tf

+6-4
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,10 @@ locals {
215215
# If a bucket name is passed, or an existing EN CRN is passed; do not create COS resources
216216
create_cos_bucket = var.enable_collecting_failed_events == false || var.existing_event_notifications_instance_crn != null ? false : true
217217
# determine COS details
218-
cos_bucket_name = var.enable_collecting_failed_events == false ? null : local.create_cos_bucket ? try("${local.prefix}-${var.cos_bucket_name}", var.cos_bucket_name) : null
219-
cos_bucket_region = var.cos_bucket_region != null ? var.cos_bucket_region : var.cross_region_location != null ? null : var.region
220-
cos_instance_guid = var.existing_event_notifications_instance_crn == null ? (var.existing_cos_instance_crn == null ? (length(module.cos_buckets) > 0 ? module.cos_buckets.bucket_configs.cos_instance_guid : null) : module.existing_cos_crn_parser[0].service_instance) : null
218+
cos_bucket_name = var.enable_collecting_failed_events == false ? null : local.create_cos_bucket ? try("${local.prefix}-${var.cos_bucket_name}", var.cos_bucket_name) : null
219+
cos_bucket_name_with_suffix = try(module.cos_buckets[0].buckets[local.cos_bucket_name].bucket_name, null)
220+
cos_bucket_region = var.cos_bucket_region != null ? var.cos_bucket_region : var.cross_region_location != null ? null : var.region
221+
cos_instance_guid = var.existing_event_notifications_instance_crn == null ? (var.existing_cos_instance_crn == null ? (length(module.cos_buckets) > 0 ? module.cos_buckets.bucket_configs.cos_instance_guid : null) : module.existing_cos_crn_parser[0].service_instance) : null
221222

222223
# If not using existing EN instance, parse the COS account ID from the CRN
223224
cos_account_id = var.existing_event_notifications_instance_crn == null ? var.existing_cos_instance_crn != null ? split("/", module.existing_cos_crn_parser[0].scope)[1] : null : null
@@ -227,6 +228,7 @@ locals {
227228
bucket_config = [{
228229
access_tags = var.cos_bucket_access_tags
229230
bucket_name = local.cos_bucket_name
231+
add_bucket_name_suffix = var.add_bucket_name_suffix
230232
kms_encryption_enabled = var.kms_encryption_enabled_bucket
231233
kms_guid = var.kms_encryption_enabled_bucket ? local.kms_instance_guid : null
232234
kms_key_crn = var.kms_encryption_enabled_bucket ? var.existing_kms_instance_crn : null
@@ -294,7 +296,7 @@ module "event_notifications" {
294296
skip_en_kms_auth_policy = local.create_cross_account_en_kms_auth_policy || var.skip_event_notifications_kms_auth_policy
295297
# COS Related
296298
cos_integration_enabled = var.enable_collecting_failed_events
297-
cos_bucket_name = local.cos_bucket_name
299+
cos_bucket_name = local.cos_bucket_name_with_suffix
298300
cos_instance_id = var.existing_cos_instance_crn
299301
skip_en_cos_auth_policy = var.skip_event_notifications_cos_auth_policy || local.create_cross_account_cos_kms_auth_policy
300302
cos_endpoint = var.existing_cos_endpoint

solutions/fully-configurable/variables.tf

+10-4
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ variable "kms_endpoint_url" {
143143

144144
variable "existing_kms_root_key_crn" {
145145
type = string
146-
description = "The key CRN of a root key, existing in the KMS instance passed in the `existing_kms_instance_crn` input, which will be used to encrypt the data. To use an existing key you must also provide a value for 'existing_event_notification_kms_key_name' and 'kms_endpoint_url'. If no value passed, a new key will be created in the instance provided in the `existing_kms_instance_crn` input."
146+
description = "The key CRN of a root key, existing in the KMS instance passed in the `existing_kms_instance_crn` input, which will be used to encrypt the data. To use an existing key you must also provide a value for 'existing_kms_key_name' and 'kms_endpoint_url'. If no value passed, a new key will be created in the instance provided in the `existing_kms_instance_crn` input."
147147
default = null
148148
validation {
149149
condition = !(var.kms_encryption_enabled == false && var.existing_kms_root_key_crn != null)
@@ -186,7 +186,7 @@ variable "event_notifications_key_ring_name" {
186186
variable "cos_key_ring_name" {
187187
type = string
188188
default = "en-cos-key-ring"
189-
description = "The name of the key ring which will be created for Object Storage. Not used if supplying an existing key or if `existing_cloud_object_storage_bucket_name` is specified. If a `prefix` input variable is specified, it is added to this name in the `<prefix>-value` format."
189+
description = "The name of the key ring which will be created for Object Storage. Not used if supplying an existing key. If a `prefix` input variable is specified, it is added to this name in the `<prefix>-value` format."
190190
}
191191

192192
variable "cos_key_name" {
@@ -203,7 +203,7 @@ variable "skip_event_notifications_kms_auth_policy" {
203203

204204
variable "ibmcloud_kms_api_key" {
205205
type = string
206-
description = "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_key_management_service_instance_crn` is in an account that's different from the Event Notifications instance. Leave this input empty if the same account owns both instances."
206+
description = "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 Event Notifications instance. Leave this input empty if the same account owns both instances."
207207
sensitive = true
208208
default = null
209209
}
@@ -245,9 +245,15 @@ variable "cos_bucket_name" {
245245
default = "base-event-notifications-bucket"
246246
}
247247

248+
variable "add_bucket_name_suffix" {
249+
type = bool
250+
description = "Whether to add a randomly generated 4-character suffix to the newly provisioned Object Storage bucket name. Used only if not using an existing bucket. Set to `false` if you want full control over bucket naming by using the `cos_bucket_name` variable."
251+
default = true
252+
}
253+
248254
variable "kms_encryption_enabled_bucket" {
249255
type = bool
250-
description = "Set to true to enable Key Protect encryption on Cloud Object Storage bucket."
256+
description = "Set to true to enable key management service encryption on Cloud Object Storage bucket."
251257
default = false
252258
}
253259

0 commit comments

Comments
 (0)