-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tf
94 lines (77 loc) · 2.17 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
data "template_file" "nomad-systemd-server" {
template = "${file("${var.localPath}/configuration/templates/systemd/nomad.tpl")}"
vars {
userName = "${var.userName}"
hclPath = "server"
}
}
data "template_file" "nomad-systemd-client" {
template = "${file("${var.localPath}/configuration/templates/systemd/nomad.tpl")}"
vars {
userName = "${var.userName}"
hclPath = "client"
}
}
data "template_file" "consul-systemd-server" {
template = "${file("${var.localPath}/configuration/templates/systemd/consul-server.tpl")}"
vars {
userName = "${var.userName}"
}
}
data "template_file" "consul-systemd-client" {
template = "${file("${var.localPath}/configuration/templates/systemd/consul-client.tpl")}"
vars {
userName = "${var.userName}"
}
}
provider "google" {
credentials = "${file("/Users/jjordan/Hashicorp/.creds/gcp/jjordan-test-a9bf57f5dfdb.json")}"
project = "${var.projectName}"
region = "${var.region}"
zone = "${var.region}-a"
}
#DATA SOURCES
data "google_compute_network" "east" {
name = "default" #maybe, but probably change this
provider = "google"
}
#FIREWALLS: NOMAD & CONSUL (TCP)
resource "google_compute_firewall" "allow-tcp" {
provider = "google"
name = "allow-tcp-east"
network = "${data.google_compute_network.east.self_link}"
allow {
protocol = "tcp"
ports = ["8300", "8301", "8302", "8500", "4646", "4647"]
}
}
#FIREWALLS: NOMAD & CONSUL (UDP)
resource "google_compute_firewall" "allow-udp" {
provider = "google"
name = "allow-udp-east"
network = "${data.google_compute_network.east.self_link}"
allow {
protocol = "udp"
ports = ["8301", "8302", "4648"]
}
}
#FIREWALLS: HTTP/S ++ :8080
resource "google_compute_firewall" "allow-service-access" {
provider = "google"
name = "http-east"
network = "${data.google_compute_network.east.self_link}"
allow {
protocol = "tcp"
ports = ["80", "443", "8080"]
}
}
#FIREWALLS: SSH
resource "google_compute_firewall" "allow-ssh" {
provider = "google"
name = "ssh-east"
network = "${data.google_compute_network.east.self_link}"
allow {
protocol = "tcp"
ports = ["22"]
}
}