-
Notifications
You must be signed in to change notification settings - Fork 4
/
001-resources.tf
100 lines (78 loc) · 2.08 KB
/
001-resources.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
provider "google" {
credentials = "${file("account.json")}"
project = "${var.ProjectName}"
region = "${var.RegionInfo.region}"
}
resource "google_compute_network" "public" {
name = "${var.StackName}"
}
resource "google_compute_subnetwork" "public" {
name = "${var.StackName}"
ip_cidr_range = "${var.ipv4_range}"
network = "${google_compute_network.public.self_link}"
region = "${var.RegionInfo.region}"
}
resource "google_compute_firewall" "ssh" {
name = "${var.StackName}-pub-ssh"
network = "${google_compute_network.public.name}"
source_ranges = ["${split(",",var.trusted_ips)}"]
allow {
protocol = "icmp"
}
allow {
protocol = "tcp"
ports = ["22", "80", "443","4980","8000","8087","8098"]
}
}
resource "google_compute_firewall" "internal" {
name = "${var.StackName}-internal-allowed"
network = "${google_compute_network.public.name}"
source_ranges = ["${var.ipv4_range}"]
allow {
protocol = "icmp"
}
allow {
protocol = "tcp"
ports = ["1-65535"]
}
allow {
protocol = "udp"
ports = ["1-65535"]
}
source_tags = ["internal"]
}
resource "google_storage_bucket" "riak" {
name = "${var.StackName}"
force_destroy = "true"
provisioner "local-exec" {
command = "gsutil -m cp -r ${var.salt_dir} gs://${var.StackName}"
}
}
resource "template_file" "master_startup" {
template = "${file("templates/master_startup.tmpl")}"
vars {
bucket_name = "${var.StackName}"
stack_name = "${var.StackName}"
salt_profiles = "${var.salt_profiles.monitor}"
}
}
resource "google_compute_instance" "monitor" {
name = "${format("${var.StackName}-monitor")}"
machine_type = "${var.machine_types.monitor}"
zone = "${var.RegionInfo.zone}"
disk {
image = "${var.google_image}"
}
network_interface = {
subnetwork = "${var.StackName}"
access_config {}
}
metadata {
startup-script = "${template_file.master_startup.rendered}"
}
service_account {
scopes = ["storage-ro"]
}
tags = ["${var.StackName}"]
depends_on = ["google_compute_subnetwork.public", "template_file.master_startup"]
}