-
Notifications
You must be signed in to change notification settings - Fork 0
/
monitoring.tf
55 lines (47 loc) · 2.22 KB
/
monitoring.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
# see https://registry.terraform.io/providers/hashicorp/Azurerm/latest/docs/resources/monitor_autoscale_setting
resource "azurerm_monitor_autoscale_setting" "main" {
name = var.autoscaling_name
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name
target_resource_id = azurerm_linux_virtual_machine_scale_set.main.id
enabled = var.autoscaling_enabled
# see https://developer.hashicorp.com/terraform/language/expressions/dynamic-blocks
dynamic "profile" {
for_each = var.autoscaling_profiles
content {
name = profile.value.name
# see https://registry.terraform.io/providers/hashicorp/Azurerm/latest/docs/resources/monitor_autoscale_setting#capacity
capacity {
default = profile.value.capacity.default
minimum = profile.value.capacity.minimum
maximum = profile.value.capacity.maximum
}
# see https://developer.hashicorp.com/terraform/language/expressions/dynamic-blocks
dynamic "rule" {
for_each = var.autoscaling_rules
content {
# see https://registry.terraform.io/providers/hashicorp/Azurerm/latest/docs/resources/monitor_autoscale_setting#metric_trigger
metric_trigger {
metric_name = rule.value.name
metric_namespace = "microsoft.compute/virtualmachinescalesets"
metric_resource_id = azurerm_linux_virtual_machine_scale_set.main.id
operator = rule.value.operator
statistic = rule.value.statistic
time_aggregation = rule.value.time_aggregation
time_grain = rule.value.time_grain
time_window = rule.value.time_window
threshold = rule.value.threshold
}
# see https://registry.terraform.io/providers/hashicorp/Azurerm/latest/docs/resources/monitor_autoscale_setting#scale_action
scale_action {
cooldown = rule.value.scale_action.cooldown
direction = rule.value.scale_action.direction
type = rule.value.scale_action.type
value = rule.value.scale_action.value
}
}
}
}
}
tags = var.tags
}