generated from cloudposse/terraform-example-module
-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
main.tf
124 lines (97 loc) · 4.23 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
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
resource "opsgenie_notification_policy" "this" {
count = module.this.enabled ? 1 : 0
enabled = try(var.notification_policy.enabled, true)
name = var.notification_policy.name
# Look up our team id by name
team_id = var.notification_policy.team_id
policy_description = try(var.notification_policy.description, var.notification_policy.name)
filter {
type = try(var.notification_policy.filter.type, "match-all")
dynamic "conditions" {
for_each = try(var.notification_policy.filter.conditions, [])
content {
field = conditions.value.field
operation = conditions.value.operation
expected_value = try(conditions.value.expected_value, "")
key = try(conditions.value.key, null)
not = try(conditions.value.not, false)
order = try(conditions.value.order, null)
}
}
}
dynamic "time_restriction" {
for_each = try(var.notification_policy.time_restriction, null) != null ? [var.notification_policy.time_restriction] : []
content {
type = time_restriction.value.type
dynamic "restrictions" {
for_each = try(time_restriction.value.restrictions, null) != null ? [time_restriction.value.restrictions] : []
content {
start_day = restrictions.value.start_day
end_day = restrictions.value.end_day
start_hour = restrictions.value.start_hour
end_hour = restrictions.value.end_hour
start_min = restrictions.value.start_min
end_min = restrictions.value.end_min
}
}
dynamic "restriction" {
for_each = try(time_restriction.value.restriction, null) != null ? [time_restriction.value.restriction] : []
content {
start_hour = restriction.value.start_hour
end_hour = restriction.value.end_hour
start_min = restriction.value.start_min
end_min = restriction.value.end_min
}
}
}
}
dynamic "auto_close_action" {
for_each = try(var.notification_policy.auto_close_action, null) != null ? [var.notification_policy.auto_close_action] : []
content {
duration {
time_amount = auto_close_action.value.duration.time_amount
time_unit = try(auto_close_action.value.duration.time_unit, "minutes")
}
}
}
dynamic "auto_restart_action" {
for_each = try(var.notification_policy.auto_restart_action, null) != null ? [var.notification_policy.auto_restart_action] : []
content {
duration {
time_amount = auto_restart_action.value.duration.time_amount
time_unit = try(auto_restart_action.value.duration.time_unit, "minutes")
}
max_repeat_count = auto_restart_action.value.max_repeat_count
}
}
dynamic "de_duplication_action" {
for_each = try(var.notification_policy.de_duplication_action, null) != null ? [var.notification_policy.de_duplication_action] : []
content {
de_duplication_action_type = de_duplication_action.value.de_duplication_action_type
count = de_duplication_action.value.count
dynamic "duration" {
for_each = de_duplication_action.value.de_duplication_action_type == "frequency-based" ? [de_duplication_action.value.duration] : [try(de_duplication_action.value.duration, null)]
content {
time_amount = duration.value.time_amount
time_unit = try(duration.value.time_unit, "minutes")
}
}
}
}
dynamic "delay_action" {
for_each = try(var.notification_policy.delay_action, null) != null ? [var.notification_policy.delay_action] : []
content {
delay_option = delay_action.value.delay_option
dynamic "duration" {
for_each = delay_action.value.delay_option == "for-duration" ? [delay_action.value.duration] : []
content {
time_amount = duration.value.time_amount
time_unit = try(duration.value.time_unit, "minutes")
}
}
until_hour = delay_action.value.delay_option != "for-duration" ? delay_action.value.until_hour : null
until_minute = delay_action.value.delay_option != "for-duration" ? delay_action.value.until_minute : null
}
}
suppress = try(var.notification_policy.suppress, null)
}