-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tf
58 lines (48 loc) · 2.12 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
# namespace -> https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/aws-services-cloudwatch-metrics.html
# metric_name -> in Documentation section
resource "aws_cloudwatch_metric_alarm" "this" {
alarm_name = format("%s-alarm", local.name)
alarm_description = var.alarm_description
actions_enabled = var.actions_enabled
alarm_actions = var.alarm_actions
ok_actions = var.ok_actions
insufficient_data_actions = var.insufficient_data_actions
comparison_operator = var.comparison_operator
evaluation_periods = var.evaluation_periods
threshold = var.threshold
unit = var.unit
datapoints_to_alarm = var.datapoints_to_alarm
treat_missing_data = var.treat_missing_data
evaluate_low_sample_count_percentiles = var.evaluate_low_sample_count_percentiles
dimensions = var.dimensions
threshold_metric_id = var.threshold_metric_id
# conflicts with metric_query
metric_name = var.metric_name
namespace = var.namespace
period = var.period
statistic = var.statistic
extended_statistic = var.extended_statistic
# conflicts with metric_name
dynamic "metric_query" {
for_each = var.metric_query
content {
id = lookup(metric_query.value, "id")
account_id = lookup(metric_query.value, "account_id", null)
label = lookup(metric_query.value, "label", null)
return_data = lookup(metric_query.value, "return_data", null)
expression = lookup(metric_query.value, "expression", null)
dynamic "metric" {
for_each = lookup(metric_query.value, "metric", [])
content {
metric_name = lookup(metric.value, "metric_name")
namespace = lookup(metric.value, "namespace")
period = lookup(metric.value, "period")
stat = lookup(metric.value, "stat")
unit = lookup(metric.value, "unit", null)
dimensions = lookup(metric.value, "dimensions", null)
}
}
}
}
tags = merge(local.tags, { "Name" = format("%s-alarm", local.name) })
}