generated from oracle/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 2
/
mon_notifications.tf
198 lines (180 loc) · 10.5 KB
/
mon_notifications.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# Copyright (c) 2023 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
locals {
#------------------------------------------------------------------------------------------------------
#-- Any of these local variables can be overriden in a _override.tf file
#------------------------------------------------------------------------------------------------------
custom_notifications_defined_tags = null
custom_notifications_freeform_tags = null
}
module "lz_notifications" {
# depends_on = [null_resource.wait_on_compartments]
source = "github.com/oci-landing-zones/terraform-oci-modules-observability//events?ref=v0.1.8"
events_configuration = local.regional_events_configuration
topics_dependency = module.lz_regional_topics.topics
}
module "lz_home_region_notifications" {
count = var.extend_landing_zone_to_new_region == false ? 1 : 0
# depends_on = [null_resource.wait_on_compartments]
source = "github.com/oci-landing-zones/terraform-oci-modules-observability//events?ref=v0.1.8"
providers = { oci = oci.home }
events_configuration = local.home_region_events_configuration
topics_dependency = module.lz_home_region_topics[0].topics
}
locals {
#------------------------------------------------------------------------------------------------------
#-- These variables are not meant to be overriden
#------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------
#----- Tags to apply to notifications
#-----------------------------------------------------------
default_notifications_defined_tags = null
default_notifications_freeform_tags = local.landing_zone_tags
notifications_defined_tags = local.custom_notifications_defined_tags != null ? merge(local.custom_notifications_defined_tags, local.default_notifications_defined_tags) : local.default_notifications_defined_tags
notifications_freeform_tags = local.custom_notifications_freeform_tags != null ? merge(local.custom_notifications_freeform_tags, local.default_notifications_freeform_tags) : local.default_notifications_freeform_tags
#--------------------------------------------------------------------
#-- IAM Events
#--------------------------------------------------------------------
iam_events_key = "IAM-EVENTS"
iam_events = {
(local.iam_events_key) = {
compartment_id = var.tenancy_ocid
event_display_name = "${var.service_label}-notify-on-iam-changes-rule"
event_description = "Landing Zone CIS related events rule to detect when IAM resources are created, updated or deleted."
preconfigured_events_categories = ["iam"]
destination_topic_ids = ["SECURITY-TOPIC"]
is_enabled = true
defined_tags = local.notifications_defined_tags
freeform_tags = local.notifications_freeform_tags
}
}
#--------------------------------------------------------------------
#-- Cloud Guard Events
#--------------------------------------------------------------------
cloudguard_events_key = "CLOUDGUARD-EVENTS"
cloudguard_events = length(var.cloud_guard_admin_email_endpoints) > 0 ? {
(local.cloudguard_events_key) = {
compartment_id = var.tenancy_ocid
event_display_name = "${var.service_label}-notify-on-cloudguard-events-rule"
event_description = "Landing Zone events rule to notify when Cloud Guard problems are Detected, Dismissed or Resolved."
preconfigured_events_categories = ["cloudguard"]
destination_topic_ids = ["CLOUDGUARD-TOPIC"]
is_enabled = true
defined_tags = local.notifications_defined_tags
freeform_tags = local.notifications_freeform_tags
}
} : {}
#--------------------------------------------------------------------
#-- Network Events
#--------------------------------------------------------------------
network_events_key = "NETWORK-EVENTS"
network_events = {
(local.network_events_key) = {
compartment_id = var.tenancy_ocid
event_display_name = "${var.service_label}-notify-on-network-changes-rule"
event_description = "Landing Zone events rule to detect when networking resources are created, updated or deleted."
preconfigured_events_categories = ["network"]
destination_topic_ids = ["NETWORK-TOPIC"]
is_enabled = true
defined_tags = local.notifications_defined_tags
freeform_tags = local.notifications_freeform_tags
}
}
#--------------------------------------------------------------------
#-- Storage Events
#--------------------------------------------------------------------
storage_events_key = "STORAGE-EVENTS"
storage_events = length(var.storage_admin_email_endpoints) > 0 ? {
(local.storage_events_key) = {
compartment_id = local.app_compartment_id
event_display_name = "${var.service_label}-notify-on-storage-changes-rule"
event_description = "Landing Zone events rule to detect when storage resources are created, updated or deleted."
preconfigured_events_categories = ["storage"]
destination_topic_ids = ["STORAGE-TOPIC"]
is_enabled = var.create_events_as_enabled
defined_tags = local.notifications_defined_tags
freeform_tags = local.notifications_freeform_tags
}
} : {}
#--------------------------------------------------------------------
#-- Database Events
#--------------------------------------------------------------------
database_events_key = "DATABASE-EVENTS"
database_events = length(var.database_admin_email_endpoints) > 0 ? {
(local.storage_events_key) = {
compartment_id = local.database_compartment_id
event_display_name = "${var.service_label}-notify-on-database-changes-rule"
event_description = "Landing Zone events rule to detect when database resources are created, updated or deleted in the database compartment."
preconfigured_events_categories = ["database"]
destination_topic_ids = ["DATABASE-TOPIC"]
is_enabled = var.create_events_as_enabled
defined_tags = local.notifications_defined_tags
freeform_tags = local.notifications_freeform_tags
}
} : {}
#--------------------------------------------------------------------
#-- Exainfra Events
#--------------------------------------------------------------------
exainfra_events_key = "EXAINFRA-EVENTS"
exainfra_events = length(var.exainfra_admin_email_endpoints) > 0 && var.deploy_exainfra_cmp == true ? {
(local.storage_events_key) = {
compartment_id = local.exainfra_compartment_id
event_display_name = "${var.service_label}-notify-on-exainfra-changes-rule"
event_description = "Landing Zone events rule to detect Exadata infrastructure events."
preconfigured_events_categories = ["exainfra"]
destination_topic_ids = ["EXAINFRA-TOPIC"]
is_enabled = var.create_events_as_enabled
defined_tags = local.notifications_defined_tags
freeform_tags = local.notifications_freeform_tags
}
} : {}
#--------------------------------------------------------------------
#-- Budget Events
#--------------------------------------------------------------------
budget_events_key = "BUDGET-EVENTS"
budget_events = length(var.budget_admin_email_endpoints) > 0 ? {
(local.budget_events_key) = {
compartment_id = var.tenancy_ocid
event_display_name = "${var.service_label}-notify-on-budget-changes-rule"
event_description = "Landing Zone events rule to detect when cost resources such as budgets and financial tracking constructs are created, updated or deleted."
preconfigured_events_categories = ["budget"]
destination_topic_ids = ["BUDGET-TOPIC"]
is_enabled = var.create_events_as_enabled
defined_tags = local.notifications_defined_tags
freeform_tags = local.notifications_freeform_tags
}
} : {}
#--------------------------------------------------------------------
#-- Compute Events
#--------------------------------------------------------------------
compute_events_key = "COMPUTE-EVENTS"
compute_events = length(var.compute_admin_email_endpoints) > 0 ? {
(local.compute_events_key) = {
compartment_id = local.app_compartment_id
event_display_name = "${var.service_label}-notify-on-compute-changes-rule"
event_description = "Landing Zone events rule to detect when compute related resources are created, updated or deleted."
preconfigured_events_categories = ["compute"]
destination_topic_ids = ["COMPUTE-TOPIC"]
is_enabled = var.create_events_as_enabled
defined_tags = local.notifications_defined_tags
freeform_tags = local.notifications_freeform_tags
}
} : {}
#------------------------------------------------------------------------
#----- Event Rules configuration definition. Input to module.
#------------------------------------------------------------------------
home_region_events = merge(local.iam_events, local.cloudguard_events)
regional_events = merge(local.network_events, local.storage_events, local.database_events, local.exainfra_events, local.budget_events, local.compute_events)
home_region_events_configuration = {
default_compartment_id = null
default_defined_tags = local.default_notifications_defined_tags
default_freeform_tags = local.default_notifications_freeform_tags
event_rules = local.home_region_events
}
regional_events_configuration = {
default_compartment_id = null
default_defined_tags = local.default_notifications_defined_tags
default_freeform_tags = local.default_notifications_freeform_tags
event_rules = local.regional_events
}
}