-
Notifications
You must be signed in to change notification settings - Fork 0
/
scale_set.tf
124 lines (107 loc) · 3.25 KB
/
scale_set.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 "azurerm_linux_virtual_machine_scale_set" "sensor_scale_set" {
admin_username = var.sensor_admin_username
admin_ssh_key {
public_key = var.sensor_ssh_public_key
username = var.sensor_admin_username
}
location = var.location
name = var.scale_set_name
resource_group_name = var.resource_group_name
sku = var.virtual_machine_size
instances = 1
custom_data = module.sensor_config.cloudinit_config.rendered
source_image_id = var.corelight_sensor_image_id
identity {
type = "SystemAssigned"
}
os_disk {
caching = "ReadWrite"
storage_account_type = "StandardSSD_LRS"
disk_size_gb = var.virtual_machine_os_disk_size
}
health_probe_id = azurerm_lb_probe.sensor_health_check_probe.id
upgrade_mode = "Automatic"
network_interface {
name = "management-nic"
primary = true
ip_configuration {
name = "management-nic-ip-cfg"
primary = true
subnet_id = azurerm_subnet.subnet.id
load_balancer_backend_address_pool_ids = [
azurerm_lb_backend_address_pool.management_pool.id
]
}
}
network_interface {
name = "monitoring-nic"
ip_configuration {
name = "monitoring-nic-ip-cfg"
primary = true
subnet_id = azurerm_subnet.subnet.id
load_balancer_backend_address_pool_ids = [
azurerm_lb_backend_address_pool.monitoring_pool.id
]
}
}
tags = var.tags
depends_on = [
azurerm_lb_rule.monitoring_health_check_rule,
]
}
resource "azurerm_monitor_autoscale_setting" "auto_scale_config" {
location = var.location
name = var.autoscale_setting_name
resource_group_name = var.resource_group_name
target_resource_id = azurerm_linux_virtual_machine_scale_set.sensor_scale_set.id
profile {
name = "autoscale"
capacity {
default = 1
minimum = 1
maximum = 5
}
rule {
metric_trigger {
metric_name = "Percentage CPU"
metric_namespace = "microsoft.compute/virtualmachinescalesets"
metric_resource_id = azurerm_linux_virtual_machine_scale_set.sensor_scale_set.id
operator = "GreaterThan"
statistic = "Average"
threshold = 70
time_aggregation = "Average"
time_grain = "PT1M"
time_window = "PT5M"
}
scale_action {
cooldown = "PT1M"
direction = "Increase"
type = "ChangeCount"
value = 1
}
}
rule {
metric_trigger {
metric_name = "Percentage CPU"
metric_namespace = "microsoft.compute/virtualmachinescalesets"
metric_resource_id = azurerm_linux_virtual_machine_scale_set.sensor_scale_set.id
time_grain = "PT1M"
statistic = "Average"
time_window = "PT5M"
time_aggregation = "Average"
operator = "LessThan"
threshold = 25
}
scale_action {
direction = "Decrease"
type = "ChangeCount"
value = "1"
cooldown = "PT1M"
}
}
}
tags = var.tags
depends_on = [
azurerm_lb_probe.sensor_health_check_probe
]
}