-
Notifications
You must be signed in to change notification settings - Fork 14
/
main.tf
137 lines (124 loc) · 4.36 KB
/
main.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
125
126
127
128
129
130
131
132
133
134
135
136
137
provider "google" {
region = "${var.region}"
}
data "google_client_config" "current" {}
resource "google_compute_network" "default" {
name = "${var.network_name}"
auto_create_subnetworks = "false"
}
resource "google_compute_subnetwork" "default" {
name = "${var.network_name}"
ip_cidr_range = "10.127.0.0/20"
network = "${google_compute_network.default.self_link}"
region = "${var.region}"
private_ip_google_access = true
}
// Master nodes
module "es_masters" {
source = "../../"
cluster_name = "${var.cluster_name}"
name = "${var.cluster_name}-master"
region = "${var.region}"
zones = "${var.zones}"
num_nodes = "${var.master_num_nodes}"
machine_type = "${var.master_machine_type}"
heap_size = "${var.master_heap_size}"
masters_count = "${var.master_num_nodes}"
master_node = true
data_node = false
access_config = []
network = "${google_compute_subnetwork.default.name}"
subnetwork = "${google_compute_subnetwork.default.name}"
}
// Data nodes
module "es_data" {
source = "../../stateful_node"
cluster_name = "${var.cluster_name}"
name = "${var.cluster_name}-data"
region = "${var.region}"
zones = "${var.zones}"
num_nodes = "${var.data_num_nodes}"
machine_type = "${var.data_machine_type}"
min_cpu_platform = ""
heap_size = "${var.data_heap_size}"
boot_disk_size_gb = 10
masters_count = "${var.master_num_nodes}"
master_node = false
data_node = true
access_config = []
network = "${google_compute_subnetwork.default.name}"
subnetwork = "${google_compute_subnetwork.default.name}"
attached_disk_1 = "${var.attached_disk_1}"
attached_disk_2 = "${var.attached_disk_2}"
attached_disk_3 = "${var.attached_disk_3}"
attached_disk_4 = "${var.attached_disk_4}"
}
// Client nodes
module "es_client" {
source = "../../"
cluster_name = "${var.cluster_name}"
name = "${var.cluster_name}-client"
region = "${var.region}"
zones = "${var.zones}"
num_nodes = "${var.client_num_nodes}"
machine_type = "${var.client_machine_type}"
heap_size = "${var.client_heap_size}"
masters_count = "${var.master_num_nodes}"
master_node = false
data_node = false
access_config = []
network = "${google_compute_subnetwork.default.name}"
subnetwork = "${google_compute_subnetwork.default.name}"
}
// Indexing nodes
module "es_indexing" {
source = "../../"
cluster_name = "${var.cluster_name}"
name = "${var.cluster_name}-indexing"
region = "${var.region}"
zones = "${var.zones}"
num_nodes = "${var.indexing_num_nodes}"
machine_type = "${var.indexing_machine_type}"
heap_size = "${var.indexing_heap_size}"
masters_count = "${var.master_num_nodes}"
master_node = false
data_node = false
access_config = []
network = "${google_compute_subnetwork.default.name}"
subnetwork = "${google_compute_subnetwork.default.name}"
}
// NAT gateway
// module "nat-gateway" {
// source = "github.com/GoogleCloudPlatform/terraform-google-nat-gateway"
// region = "${var.region}"
// zone = "${element(var.zones, 0)}"
// network = "${google_compute_subnetwork.default.name}"
// subnetwork = "${google_compute_subnetwork.default.name}"
// tags = ["${var.cluster_name}"]
// }
// Kibana
module "kibana" {
source = "../../kibana"
name = "${var.cluster_name}-kibana"
region = "${var.region}"
zones = ["${var.zones}"]
access_config = []
num_nodes = 1
elasticsearch_url = "http://${module.es_client_ilb.ip_address}:9200"
network = "${google_compute_subnetwork.default.name}"
subnetwork = "${google_compute_subnetwork.default.name}"
}
// Cluster firewall
resource "google_compute_firewall" "cluster" {
name = "${var.cluster_name}"
network = "${google_compute_subnetwork.default.name}"
allow {
protocol = "tcp"
ports = ["9200", "9300"]
}
source_tags = ["${var.cluster_name}", "${var.cluster_name}-external"]
target_tags = ["${var.cluster_name}"]
}
output "kibana_hostname" {
value = "${basename(lookup(module.kibana.instances[0], "instance"))}"
}