forked from vinnie357/demo-nginx-consul-gcp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconsul.tf
62 lines (56 loc) · 1.67 KB
/
consul.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
# template
# Setup Onboarding scripts
data template_file consul_onboard {
template = file("${path.module}/templates/consul/startup.sh.tpl")
vars = {
CONSUL_VERSION = "1.7.2"
zone = var.gcpZone
project = var.gcpProjectId
}
}
resource google_compute_instance_template consul-template {
name_prefix = "consul-template-"
description = "This template is used to create runner server instances."
tags = ["consul-demo"]
instance_description = "consul"
machine_type = "n1-standard-4"
can_ip_forward = false
disk {
source_image = "ubuntu-os-cloud/ubuntu-1804-lts"
auto_delete = true
boot = true
type = "pd-ssd"
}
network_interface {
network = google_compute_network.vpc_network.id
subnetwork = google_compute_subnetwork.vpc_network_sub.id
access_config {
}
}
lifecycle {
create_before_destroy = true
}
metadata = {
startup-script = data.template_file.consul_onboard.rendered
#shutdown-script = "${file("${path.module}/templates/consul/shutdown.sh")}"
}
service_account {
#email = google_service_account.consul-sa.email
scopes = ["cloud-platform"]
}
}
# instance group
resource google_compute_instance_group_manager consul-group {
depends_on = [google_container_cluster.primary]
name = "${var.projectPrefix}-consul-instance-group-manager"
base_instance_name = "${var.projectPrefix}-consul"
zone = var.gcpZone
target_size = 3
version {
instance_template = google_compute_instance_template.consul-template.id
}
# wait for gke cluster
timeouts {
create = "15m"
}
}