File tree Expand file tree Collapse file tree 4 files changed +25
-5
lines changed Expand file tree Collapse file tree 4 files changed +25
-5
lines changed Original file line number Diff line number Diff 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
125133module "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
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 44
55output "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
1010output "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
1515output "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
2020output "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
2626output "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}
Original file line number Diff line number Diff 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# #######################################################################################################################
You can’t perform that action at this time.
0 commit comments