-
Notifications
You must be signed in to change notification settings - Fork 8
/
terraform.tf
104 lines (86 loc) · 2.12 KB
/
terraform.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
terraform {
backend "gcs" {
project = "digital-seat-198720"
bucket = "digital-seat-198720"
path = "terraform.tfstate"
}
}
provider "google" {
version = "~> 1.7"
project = "digital-seat-198720"
region = "us-east1"
}
# Be advised, Terraform's state is stored in this bucket
resource "google_storage_bucket" "digital-seat-198720" {
name = "digital-seat-198720"
storage_class = "REGIONAL"
location = "us-east1"
versioning {
enabled = true
}
}
resource "google_compute_disk" "data" {
name = "data"
type = "pd-ssd"
zone = "us-east1-d"
size = 10
}
resource "google_compute_network" "main" {
name = "main"
}
resource "google_compute_firewall" "main" {
name = "main"
network = "${google_compute_network.main.self_link}"
allow {
protocol = "icmp" # For IPv6
}
allow {
protocol = "tcp"
ports = ["22", "80", "443"]
}
}
resource "google_compute_instance" "main" {
name = "main"
machine_type = "f1-micro"
zone = "us-east1-d"
boot_disk {
initialize_params {
image = "cos-cloud/cos-stable"
}
}
attached_disk {
source = "${google_compute_disk.data.self_link}"
device_name = "data"
}
network_interface {
network = "${google_compute_network.main.self_link}"
access_config {}
}
service_account {
scopes = ["storage-ro"] # For GCR
}
metadata_startup_script = <<EOF
mkdir -p /mnt/disks/data &&
mount /dev/disk/by-id/google-data /mnt/disks/data &&
su - user -c 'cd ~ && . scripts/docker-compose up -d'
EOF
}
variable "cloudflare_email" {}
variable "cloudflare_token" {}
provider "cloudflare" {
version = "~> 0.1"
email = "${var.cloudflare_email}"
token = "${var.cloudflare_token}"
}
resource "cloudflare_record" "frontend" {
domain = "auzom.gg"
name = "legacy"
type = "A"
value = "${google_compute_instance.main.network_interface.0.access_config.0.assigned_nat_ip}"
}
resource "cloudflare_record" "backend" {
domain = "auzom.gg"
name = "api.legacy"
type = "A"
value = "${google_compute_instance.main.network_interface.0.access_config.0.assigned_nat_ip}"
}