-
Notifications
You must be signed in to change notification settings - Fork 0
/
auto_maintenance_window.tf
73 lines (72 loc) · 2.43 KB
/
auto_maintenance_window.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
resource "dynatrace_maintenance" "auto_shutdown_blackout" {
/*
maintenance mode enabled for given environment to acommodate the
out of hours AKS cluster shutdown's during weekdays
See :https://github.com/hmcts/aks-auto-shutdown
*/
enabled = var.automated_weekday_maintenance
filters {
filter {
entity_tags = ["ENVIRONMENT:${var.env}"]
entity_type = "HTTP_CHECK"
}
}
general_properties {
name = "Cluster Auto-Shutdown for ${var.env} environment"
description = "All nonprod envs besides AAT are shutdown out of hours. This maintenance window stops alerting and HTTP monitors for all HTTP monitors in ${var.env} environment. The maintenance window starts after this as the clusters take some time to build."
type = "PLANNED"
disable_synthetic = true
suppression = "DONT_DETECT_PROBLEMS"
}
schedule {
type = "DAILY"
daily_recurrence {
recurrence_range {
start_date = var.auto_window_start_date
end_date = var.auto_window_end_date
}
time_window {
start_time = var.auto_window_start_time
end_time = var.auto_window_end_time
time_zone = "UTC"
}
}
}
}
resource "dynatrace_maintenance" "auto_shutdown_weekends" {
/*
maintenance mode enabled for given environment to acommodate the
out of hours AKS cluster shutdown's during weekends when we power off
See :https://github.com/hmcts/aks-auto-shutdown
*/
enabled = var.automated_weekend_maintenance
for_each = local.weekend_days
filters {
filter {
entity_tags = ["ENVIRONMENT:${var.env}"]
entity_type = "HTTP_CHECK"
}
}
general_properties {
name = "Cluster power-off in ${var.env} environment on ${title(lower(each.key))}"
description = "All nonprod envs besides AAT are shutdown out of hours. This maintenance window stops alerting and HTTP monitors for all HTTP monitors in ${var.env} environment"
type = "PLANNED"
disable_synthetic = true
suppression = "DONT_DETECT_PROBLEMS"
}
schedule {
type = "WEEKLY"
weekly_recurrence {
day_of_week = each.key
recurrence_range {
start_date = var.auto_window_start_date
end_date = var.auto_window_end_date
}
time_window {
start_time = var.weekend_window_start_time
end_time = var.weekend_window_end_time
time_zone = "UTC"
}
}
}
}