-
Notifications
You must be signed in to change notification settings - Fork 0
/
instance.tf
71 lines (58 loc) · 2.01 KB
/
instance.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
resource "google_compute_instance_template" "sensor_template" {
name_prefix = var.instance_template_resource_name_prefix
machine_type = var.instance_size
tags = ["allow-ssh", "corelight", "sensor", "allow-health-check"]
dynamic "service_account" {
for_each = var.sensor_service_account_email == "" ? toset([]) : toset([1])
content {
scopes = ["cloud-platform"]
email = var.sensor_service_account_email
}
}
disk {
source_image = var.image
disk_size_gb = var.image_disk_size
auto_delete = true
boot = true
}
metadata = {
ssh-keys = "${var.instance_ssh_user}:${file(var.instance_ssh_key_pub)}"
user-data = module.sensor_config.cloudinit_config.rendered
}
network_interface {
network = var.network_mgmt_name
subnetwork = var.subnetwork_mgmt_name
}
network_interface {
network = var.network_prod_name
subnetwork = var.subnetwork_mon_name
}
lifecycle {
create_before_destroy = true
}
}
resource "google_compute_region_instance_group_manager" "sensor_mig" {
name = var.instance_template_group_manager_resource_name
region = var.region
base_instance_name = var.instance_template_group_manager_base_instance_name
version {
instance_template = google_compute_instance_template.sensor_template.id
name = "Corelight-Sensor"
}
auto_healing_policies {
health_check = google_compute_region_health_check.traffic_mon_health_check.id
initial_delay_sec = 600
}
}
resource "google_compute_region_autoscaler" "sensor_autoscaler" {
name = var.region_autoscaler_resource_name
target = google_compute_region_instance_group_manager.sensor_mig.id
autoscaling_policy {
max_replicas = var.region_autoscaler_policy_max_replicas
min_replicas = var.region_autoscaler_policy_min_replicas
cooldown_period = var.region_autoscaler_policy_cooldown_period
cpu_utilization {
target = var.region_autoscaler_policy_cpu_utilization_target
}
}
}