-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
35 lines (29 loc) · 1 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
locals {
rules_merged = merge(var.rule_overrides, local.rules_default)
}
resource "aws_cloudwatch_log_metric_filter" "this" {
for_each = local.rules_merged
name = each.key
log_group_name = var.log_group_name
pattern = each.value.pattern
metric_transformation {
name = each.key
namespace = var.alarm_namespace
value = "1"
}
}
resource "aws_cloudwatch_metric_alarm" "this" {
for_each = local.rules_merged
alarm_name = each.key
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = "1"
metric_name = aws_cloudwatch_log_metric_filter.this[each.key].id
namespace = var.alarm_namespace
period = try(each.value.period, 300)
statistic = "Sum"
threshold = "1"
alarm_description = each.value.description
alarm_actions = var.alarm_action_arns
treat_missing_data = "notBreaching"
insufficient_data_actions = []
}