-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
80 lines (58 loc) · 1.45 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
data "google_compute_subnetwork" "db" {
name = "${var.subnetwork_name}"
}
locals {
name = "${var.name}-db"
}
resource "google_compute_instance" "db" {
name = "${local.name}"
machine_type = "n1-standard-1"
zone = "us-west1-a"
allow_stopping_for_update = true
labels = {
name = "db"
}
tags = ["db"]
boot_disk {
initialize_params {
image = "ubuntu-os-cloud/ubuntu-1604-lts"
}
}
// Local SSD disk
scratch_disk {}
network_interface {
subnetwork = "${data.google_compute_subnetwork.db.self_link}"
access_config {
// Ephemeral IP
}
}
metadata {
sshKeys = "ubuntu:${file(var.ssh_public_key_filepath)}"
block-project-ssh-keys = "TRUE"
startup-script = "${file("${path.module}/files/install.sh")}"
}
}
resource "google_compute_firewall" "allow_ssh_ingress" {
name = "${local.name}-allow-ssh-ingress"
network = "${data.google_compute_subnetwork.db.network}"
direction = "INGRESS"
priority = 999
allow {
protocol = "tcp"
ports = ["22"]
}
source_ranges = "${var.engineer_cidrs}"
target_tags = ["db"]
}
resource "google_compute_firewall" "allow_ui_ingress" {
name = "${local.name}-allow-ui-ingress"
network = "${data.google_compute_subnetwork.db.network}"
direction = "INGRESS"
priority = 998
allow {
protocol = "tcp"
ports = ["8080"]
}
source_ranges = "${var.engineer_cidrs}"
target_tags = ["db"]
}