Skip to content

Commit 486669e

Browse files
authored
feat: added support to the DA solution to supply and existing EN instance using the existing_en_instance_crn input (#243)
1 parent 91daf6a commit 486669e

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

solutions/standard/main.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,18 @@ locals {
120120
# KMS Related
121121
existing_kms_instance_crn = var.existing_kms_instance_crn != null ? var.existing_kms_instance_crn : null
122122
cos_endpoint = var.existing_cos_bucket_name == null ? "https://${module.cos[0].s3_endpoint_public}" : var.existing_cos_endpoint
123+
# Event Notification Related
124+
parsed_existing_en_instance_crn = var.existing_en_instance_crn != null ? split(":", var.existing_en_instance_crn) : []
125+
existing_en_guid = length(local.parsed_existing_en_instance_crn) > 0 ? local.parsed_existing_en_instance_crn[7] : null
126+
}
127+
128+
data "ibm_resource_instance" "existing_en" {
129+
count = var.existing_en_instance_crn == null ? 0 : 1
130+
identifier = var.existing_en_instance_crn
123131
}
124132

125133
module "event_notifications" {
134+
count = var.existing_en_instance_crn != null ? 0 : 1
126135
source = "../.."
127136
resource_group_id = module.resource_group.resource_group_id
128137
region = var.region

solutions/standard/moved.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ moved {
22
from = module.cos
33
to = module.cos[0]
44
}
5+
6+
moved {
7+
from = module.event_notifications
8+
to = module.event_notifications[0]
9+
}

solutions/standard/outputs.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@
44

55
output "event_notification_instance_name" {
66
description = "Event Notification name"
7-
value = module.event_notifications.event_notification_instance_name
7+
value = var.existing_en_instance_crn == null ? module.event_notifications[0].event_notification_instance_name : data.ibm_resource_instance.existing_en[0].name
88
}
99

1010
output "crn" {
1111
description = "Event Notification crn"
12-
value = module.event_notifications.crn
12+
value = var.existing_en_instance_crn == null ? module.event_notifications[0].crn : var.existing_en_instance_crn
1313
}
1414

1515
output "guid" {
1616
description = "Event Notification guid"
17-
value = module.event_notifications.guid
17+
value = var.existing_en_instance_crn == null ? module.event_notifications[0].guid : local.existing_en_guid
1818
}
1919

2020
output "service_credentials_json" {
2121
description = "Service credentials json map"
22-
value = module.event_notifications.service_credentials_json
22+
value = var.existing_en_instance_crn == null ? module.event_notifications[0].service_credentials_json : null
2323
sensitive = true
2424
}
2525

2626
output "service_credentials_object" {
2727
description = "Service credentials object"
28-
value = module.event_notifications.service_credentials_object
28+
value = var.existing_en_instance_crn == null ? module.event_notifications[0].service_credentials_object : null
2929
sensitive = true
3030
}

solutions/standard/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ variable "tags" {
8686
default = []
8787
}
8888

89+
variable "existing_en_instance_crn" {
90+
type = string
91+
description = "The CRN of existing event notification instance. If not supplied, a new instance is created."
92+
default = null
93+
}
94+
8995
########################################################################################################################
9096
# KMS
9197
########################################################################################################################

0 commit comments

Comments
 (0)