-
Notifications
You must be signed in to change notification settings - Fork 0
/
instance.tf
69 lines (57 loc) · 1.54 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
resource "google_compute_disk" "disk_clickhouse" {
name = "disk-clickhouse"
type = "pd-ssd"
zone = var.zone
size = 10 # Size in GB
}
resource "google_compute_attached_disk" "default" {
disk = google_compute_disk.disk_clickhouse.self_link
device_name = var.device_name
instance = google_compute_instance.instance_clickhouse.self_link
zone = var.zone
}
resource "google_compute_instance" "instance_clickhouse" {
name = "instance-clickhouse"
machine_type = "e2-medium"
zone = var.zone
tags = ["http-server", "https-server"]
boot_disk {
auto_delete = true
device_name = "instance-clickhouse"
initialize_params {
image = "debian-cloud/debian-12"
}
mode = "READ_WRITE"
}
network_interface {
access_config {
nat_ip = google_compute_address.static_ip.address
}
queue_count = 0
stack_type = "IPV4_ONLY"
network="default"
}
scheduling {
automatic_restart = true
on_host_maintenance = "MIGRATE"
preemptible = false
provisioning_model = "STANDARD"
}
shielded_instance_config {
enable_integrity_monitoring = true
enable_secure_boot = false
enable_vtpm = true
}
# YOU NEED THIS TO PREVENT DISK ATTACHMENT LOOP
lifecycle {
ignore_changes = [attached_disk]
}
metadata = {
ssh-keys = join("\n", [for user_key in var.ssh_keys : "${user_key.user}:${user_key.key}"]),
startup-script = templatefile("files/init.sh",
{
"device_name": var.device_name
}
)
}
}