Skip to content

Commit d1f4d59

Browse files
authored
feat: updated the schema of the existing_event_notifications_instances input (now required CRN instead of id and region)<br>* enabled the DA with add-ons (#64)
1 parent dd35c3f commit d1f4d59

File tree

17 files changed

+270
-224
lines changed

17 files changed

+270
-224
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ You need the following permissions to run this module.
153153
| <a name="input_access_tags"></a> [access\_tags](#input\_access\_tags) | A list of access tags to apply to the IBM Cloud Logs instance created by the module. For more information, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial. | `list(string)` | `[]` | no |
154154
| <a name="input_cbr_rules"></a> [cbr\_rules](#input\_cbr\_rules) | (Optional, list) List of context-based restrictions rules to create | <pre>list(object({<br/> description = string<br/> account_id = string<br/> rule_contexts = list(object({<br/> attributes = optional(list(object({<br/> name = string<br/> value = string<br/> }))) }))<br/> enforcement_mode = string<br/> operations = optional(list(object({<br/> api_types = list(object({<br/> api_type_id = string<br/> }))<br/> })))<br/> }))</pre> | `[]` | no |
155155
| <a name="input_data_storage"></a> [data\_storage](#input\_data\_storage) | A logs data bucket and a metrics bucket in IBM Cloud Object Storage to store your IBM Cloud Logs data for long term storage, search, analysis and alerting. | <pre>object({<br/> logs_data = optional(object({<br/> enabled = optional(bool, false)<br/> bucket_crn = optional(string)<br/> bucket_endpoint = optional(string)<br/> skip_cos_auth_policy = optional(bool, false)<br/> }), {})<br/> metrics_data = optional(object({<br/> enabled = optional(bool, false)<br/> bucket_crn = optional(string)<br/> bucket_endpoint = optional(string)<br/> skip_cos_auth_policy = optional(bool, false)<br/> }), {})<br/> }<br/> )</pre> | <pre>{<br/> "logs_data": null,<br/> "metrics_data": null<br/>}</pre> | no |
156-
| <a name="input_existing_event_notifications_instances"></a> [existing\_event\_notifications\_instances](#input\_existing\_event\_notifications\_instances) | List of Event Notifications instance details for routing critical events that occur in your IBM Cloud Logs. | <pre>list(object({<br/> en_instance_id = string<br/> en_region = string<br/> en_integration_name = optional(string)<br/> skip_en_auth_policy = optional(bool, false)<br/> }))</pre> | `[]` | no |
156+
| <a name="input_existing_event_notifications_instances"></a> [existing\_event\_notifications\_instances](#input\_existing\_event\_notifications\_instances) | List of Event Notifications instance details for routing critical events that occur in your IBM Cloud Logs. | <pre>list(object({<br/> crn = string<br/> integration_name = optional(string)<br/> skip_iam_auth_policy = optional(bool, false)<br/> }))</pre> | `[]` | no |
157157
| <a name="input_instance_name"></a> [instance\_name](#input\_instance\_name) | The name of the IBM Cloud Logs instance to create. Defaults to 'cloud-logs-<region>' | `string` | `null` | no |
158158
| <a name="input_logs_routing_tenant_regions"></a> [logs\_routing\_tenant\_regions](#input\_logs\_routing\_tenant\_regions) | Pass a list of regions to create a tenant for that is targetted to the IBM Cloud Logs instance created by this module. To manage platform logs that are generated by IBM Cloud® services in a region of IBM Cloud, you must create a tenant in each region that you operate. Leave the list empty if you don't want to create any tenants. NOTE: You can only have 1 tenant per region in an account. | `list(any)` | `[]` | no |
159159
| <a name="input_plan"></a> [plan](#input\_plan) | The IBM Cloud Logs plan to provision. Available: standard | `string` | `"standard"` | no |

examples/advanced/main.tf

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,12 @@ module "cloud_logs" {
177177
}]
178178
}]
179179
existing_event_notifications_instances = [{
180-
en_instance_id = module.event_notification_1.guid
181-
en_region = var.region
182-
en_integration_name = "${var.prefix}-en-1"
180+
crn = module.event_notification_1.crn
181+
integration_name = "${var.prefix}-en-1"
183182
},
184183
{
185-
en_instance_id = module.event_notification_2.guid
186-
en_region = var.region
187-
en_integration_name = "${var.prefix}-en-2"
184+
crn = module.event_notification_2.crn
185+
integration_name = "${var.prefix}-en-2"
188186
}]
189187

190188
cbr_rules = [{

ibm_catalog.json

Lines changed: 155 additions & 79 deletions
Large diffs are not rendered by default.

modules/webhook/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ No modules.
4949
| <a name="input_cloud_logs_instance_id"></a> [cloud\_logs\_instance\_id](#input\_cloud\_logs\_instance\_id) | The GUID of the existing IBM Cloud Logs instance. | `string` | n/a | yes |
5050
| <a name="input_cloud_logs_instance_name"></a> [cloud\_logs\_instance\_name](#input\_cloud\_logs\_instance\_name) | The name of the existing IBM Cloud Logs instance. It is used as a prefix for the outgoing webhook name if the existing\_event\_notification\_instances does not set en\_integration\_name. | `string` | n/a | yes |
5151
| <a name="input_cloud_logs_region"></a> [cloud\_logs\_region](#input\_cloud\_logs\_region) | The IBM Cloud region where the existing Cloud Logs instance is located. | `string` | n/a | yes |
52-
| <a name="input_existing_event_notifications_instances"></a> [existing\_event\_notifications\_instances](#input\_existing\_event\_notifications\_instances) | List of Event Notifications instance details for routing critical events that occur in your IBM Cloud Logs. | <pre>list(object({<br/> en_instance_id = string<br/> en_region = string<br/> en_integration_name = optional(string)<br/> skip_en_auth_policy = optional(bool, false)<br/> }))</pre> | n/a | yes |
52+
| <a name="input_existing_event_notifications_instances"></a> [existing\_event\_notifications\_instances](#input\_existing\_event\_notifications\_instances) | List of Event Notifications instance details for routing critical events that occur in your IBM Cloud Logs. | <pre>list(object({<br/> crn = string<br/> integration_name = optional(string)<br/> skip_iam_auth_policy = optional(bool, false)<br/> }))</pre> | n/a | yes |
5353

5454
### Outputs
5555

modules/webhook/main.tf

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

55
# Create IAM Authorization Policies to allow Cloud Logs to access event notification
66
resource "ibm_iam_authorization_policy" "en_policy" {
7-
for_each = { for idx, en in var.existing_event_notifications_instances : idx => en if !en.skip_en_auth_policy }
7+
for_each = { for idx, en in var.existing_event_notifications_instances : idx => en if !en.skip_iam_auth_policy }
88
source_service_name = "logs"
99
source_resource_instance_id = var.cloud_logs_instance_id
1010
target_service_name = "event-notifications"
11-
target_resource_instance_id = each.value.en_instance_id
11+
target_resource_instance_id = split(":", each.value.crn)[7]
1212
roles = ["Event Source Manager", "Viewer"]
13-
description = "Allow Cloud Logs with instance ID ${var.cloud_logs_instance_id} 'Event Source Manager' and 'Viewer' role access on the Event Notification instance GUID ${each.value.en_instance_id}"
13+
description = "Allow Cloud Logs with instance ID ${var.cloud_logs_instance_id} 'Event Source Manager' and 'Viewer' role access on the Event Notification instance GUID ${split(":", each.value.crn)[7]}"
1414
}
1515

1616
resource "time_sleep" "wait_for_en_authorization_policy" {
@@ -23,11 +23,11 @@ resource "ibm_logs_outgoing_webhook" "en_integration" {
2323
for_each = { for idx, en in var.existing_event_notifications_instances : idx => en }
2424
instance_id = var.cloud_logs_instance_id
2525
region = var.cloud_logs_region
26-
name = each.value.en_integration_name == null ? "${var.cloud_logs_instance_name}-en-integration-${each.key}" : each.value.en_integration_name
26+
name = each.value.integration_name == null ? "${var.cloud_logs_instance_name}-en-integration-${each.key}" : each.value.integration_name
2727
type = "ibm_event_notifications"
2828

2929
ibm_event_notifications {
30-
event_notifications_instance_id = each.value.en_instance_id
31-
region_id = each.value.en_region
30+
event_notifications_instance_id = split(":", each.value.crn)[7]
31+
region_id = split(":", each.value.crn)[5]
3232
}
3333
}

modules/webhook/variables.tf

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ variable "cloud_logs_instance_name" {
1919

2020
variable "existing_event_notifications_instances" {
2121
type = list(object({
22-
en_instance_id = string
23-
en_region = string
24-
en_integration_name = optional(string)
25-
skip_en_auth_policy = optional(bool, false)
22+
crn = string
23+
integration_name = optional(string)
24+
skip_iam_auth_policy = optional(bool, false)
2625
}))
2726
description = "List of Event Notifications instance details for routing critical events that occur in your IBM Cloud Logs."
2827
}

reference-architecture/deployable-architecture-cloud-logs.svg

Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)