-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
74 lines (64 loc) · 2.35 KB
/
main.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
module "labels" {
source = "clouddrove/labels/azure"
version = "1.0.0"
name = var.name
environment = var.environment
managedby = var.managedby
label_order = var.label_order
repository = var.repository
}
resource "azurerm_monitor_action_group" "group" {
for_each = var.actionGroups
name = each.value.actionGroupName
resource_group_name = each.value.actionGroupRGName
short_name = each.value.actionGroupShortName
enabled = each.value.actionGroupEnabled
dynamic "email_receiver" {
for_each = each.value.actionGroupEmailReceiver
content {
name = email_receiver.value["name"]
email_address = email_receiver.value["email_address"]
use_common_alert_schema = email_receiver.value["use_common_alert_schema"]
}
}
tags = module.labels.tags
}
resource "azurerm_monitor_metric_alert" "alert" {
for_each = var.metricAlerts
name = each.value.alertName
resource_group_name = each.value.alertResourceGroupName
scopes = each.value.alertScopes
description = each.value.alertDescription
enabled = each.value.alertEnabled
auto_mitigate = each.value.alertAutoMitigate
frequency = each.value.alertFrequency
target_resource_type = each.value.alertTargetResourceType
target_resource_location = each.value.alertTargetResourceLoc
criteria {
metric_namespace = each.value.dynCriteriaMetricNamespace
metric_name = each.value.dynCriteriaMetricName
aggregation = each.value.dynCriteriaAggregation
operator = each.value.dynCriteriaOperator
threshold = each.value.dynCriteriathreshold
}
action {
action_group_id = each.value.actionGroupID
}
tags = module.labels.tags
}
resource "azurerm_monitor_activity_log_alert" "main" {
for_each = var.activity_log_alert
name = each.value.alertname
resource_group_name = each.value.alertrg
scopes = each.value.alertscopes
description = each.value.description
criteria {
operation_name = each.value.operation_name
category = each.value.category
resource_group = each.value.alertrg
}
action {
action_group_id = each.value.actionGroupID
}
tags = module.labels.tags
}