Skip to content

Commit e2b9862

Browse files
committed
Split the infra into two GCP projects and two tf configs
1 parent 90888af commit e2b9862

21 files changed

+930
-376
lines changed

classic-tf/.terraform.lock.hcl

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

classic-tf/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Terraform config
2+
3+
This is our production terraform. We have only started using it recently, and
4+
so we are slowly migrating it over, as we make changes to config.
5+
6+
I made a deliberate choice not to just migrate everything over to reduce the
7+
risk of breaking something. Fortunately, if it's not imported into the state
8+
then terraform won't try to manage it (and hence won't try to delete it).

classic-tf/apis.tf

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Cloud Run
2+
resource "google_project_service" "cloud_run_api" {
3+
provider = google
4+
service = "run.googleapis.com"
5+
disable_on_destroy = false
6+
}

classic-tf/cloudrun.tf

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
2+
# resource "google_cloud_run_service" "bwdserver" {
3+
# name = "bwdserver"
4+
# location = "us-west1"
5+
6+
# template {
7+
8+
# metadata {
9+
# annotations = {
10+
# "autoscaling.knative.dev/minScale" : "0"
11+
# "autoscaling.knative.dev/maxScale" : "0"
12+
# "run.googleapis.com/startup-cpu-boost" : "true"
13+
# "run.googleapis.com/cpu-throttling" : "true"
14+
# "run.googleapis.com/execution-environment" : "gen2"
15+
# }
16+
# }
17+
18+
# spec {
19+
# timeout_seconds = 300
20+
# service_account_name = "cloud-run-runner@balmy-ground-195100.iam.gserviceaccount.com"
21+
# containers {
22+
# image = "gcr.io/balmy-ground-195100/gcp-fsharp-bwdserver@sha256:ec7bbcd9e38d8965b76d5718359fac1242fefdcb11ae7250ed918415ecd829a3"
23+
# ports {
24+
# name = "http1"
25+
# container_port = 11001
26+
# }
27+
# resources {
28+
# requests = {
29+
# "cpu" = "2.0"
30+
# "memory" = "4000Mi"
31+
# }
32+
# limits = {
33+
# cpu = "2.0"
34+
# memory = "6000Mi"
35+
# }
36+
# }
37+
# # startup_probe {
38+
# # initial_delay_seconds = 0
39+
# # timeout_seconds = 1
40+
# # period_seconds = 3
41+
# # failure_threshold = 1
42+
# # tcp_socket {
43+
# # port = 8080
44+
# # }
45+
# # }
46+
# # liveness_probe {
47+
# # http_get {
48+
# # path = "/"
49+
# # }
50+
# # }
51+
52+
# # secrets
53+
# dynamic "env" {
54+
# for_each = var.service_secrets
55+
# content {
56+
# name = env.key
57+
# value_from {
58+
# secret_key_ref {
59+
# name = env.value
60+
# key = "latest"
61+
# }
62+
# }
63+
# }
64+
# }
65+
66+
# # Env vars
67+
# dynamic "env" {
68+
# for_each = var.service_env_vars
69+
# content {
70+
# name = env.key
71+
# value = env.value
72+
# }
73+
# }
74+
# }
75+
# }
76+
# }
77+
78+
# traffic {
79+
# percent = 100
80+
# latest_revision = true
81+
# }
82+
83+
# depends_on = [google_project_service.cloud_run_api]
84+
# }

classic-tf/cloudstorage.tf

+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
##########################
2+
# Used by container registry
3+
##########################
4+
5+
resource "google_storage_bucket" "artifacts_balmy_ground_195100_appspot_com" {
6+
force_destroy = false
7+
location = "US"
8+
name = "artifacts.balmy-ground-195100.appspot.com"
9+
project = local.project_name
10+
public_access_prevention = "inherited"
11+
storage_class = "STANDARD"
12+
}
13+
resource "google_storage_bucket" "us_artifacts_balmy_ground_195100_appspot_com" {
14+
force_destroy = false
15+
location = "US"
16+
name = "us.artifacts.balmy-ground-195100.appspot.com"
17+
project = local.project_name
18+
public_access_prevention = "inherited"
19+
storage_class = "STANDARD"
20+
}
21+
22+
##########################
23+
# Darklang classic
24+
##########################
25+
26+
# Bucket to download the rust-based static assets cli
27+
resource "google_storage_bucket" "dark_cli" {
28+
force_destroy = false
29+
location = "US"
30+
name = "dark-cli"
31+
project = local.project_name
32+
public_access_prevention = "inherited"
33+
storage_class = "STANDARD"
34+
website {
35+
main_page_suffix = "index.html"
36+
not_found_page = "404.html"
37+
}
38+
}
39+
40+
# For assets used as part of the osx cross-compilation used by the rust-based cli
41+
resource "google_storage_bucket" "dark_osxcross_files" {
42+
force_destroy = false
43+
location = "US"
44+
name = "dark-osxcross-files"
45+
project = local.project_name
46+
public_access_prevention = "inherited"
47+
storage_class = "STANDARD"
48+
}
49+
50+
# Bucket for storing customer static assets on darklang-classic
51+
resource "google_storage_bucket" "dark_static_assets" {
52+
cors {
53+
max_age_seconds = 3600
54+
method = ["GET"]
55+
origin = ["*"]
56+
response_header = ["Content-Type"]
57+
}
58+
force_destroy = false
59+
location = "US"
60+
name = "dark-static-assets"
61+
project = local.project_name
62+
public_access_prevention = "inherited"
63+
storage_class = "STANDARD"
64+
website {
65+
main_page_suffix = "index.html"
66+
not_found_page = "404.html"
67+
}
68+
}
69+
70+
# Dev-environment bucket for testing static assets on darklang-classic
71+
resource "google_storage_bucket" "dark_static_assets_dev" {
72+
force_destroy = false
73+
location = "US"
74+
name = "dark-static-assets-dev"
75+
project = local.project_name
76+
public_access_prevention = "inherited"
77+
storage_class = "STANDARD"
78+
website {
79+
not_found_page = "404.html"
80+
}
81+
}
82+
83+
# Bucket for storing customer traces on darklang-classic
84+
resource "google_storage_bucket" "dark_traces" {
85+
force_destroy = false
86+
location = "US-WEST1"
87+
name = "dark-traces"
88+
project = local.project_name
89+
public_access_prevention = "enforced"
90+
storage_class = "STANDARD"
91+
uniform_bucket_level_access = true
92+
}
93+
94+
# Bucket for static assets for the old editor (darklang-classic)
95+
resource "google_storage_bucket" "darklang_static_assets" {
96+
cors {
97+
max_age_seconds = 3600
98+
method = ["GET"]
99+
origin = ["https://*.darklang.com", "https://darklang.com"]
100+
response_header = ["Content-Type"]
101+
}
102+
force_destroy = false
103+
location = "US"
104+
name = "darklang-static-assets"
105+
project = local.project_name
106+
public_access_prevention = "inherited"
107+
storage_class = "STANDARD"
108+
uniform_bucket_level_access = true
109+
website {
110+
not_found_page = "404.html"
111+
}
112+
}
113+
114+
##########################
115+
# Darklang AI deployment
116+
##########################
117+
118+
# Downloads for the new cli(s)
119+
resource "google_storage_bucket" "darklang_downloads" {
120+
force_destroy = false
121+
location = "US"
122+
name = "darklang-downloads"
123+
project = local.project_name
124+
public_access_prevention = "inherited"
125+
storage_class = "STANDARD"
126+
uniform_bucket_level_access = true
127+
autoclass {
128+
enabled = true
129+
}
130+
}
131+
132+
# Bucket for storing customer traces on darklang-classic
133+
resource "google_storage_bucket" "dark_traces_ai" {
134+
force_destroy = false
135+
location = "US-WEST1"
136+
name = "dark-traces-ai"
137+
project = local.project_name
138+
public_access_prevention = "enforced"
139+
storage_class = "STANDARD"
140+
uniform_bucket_level_access = true
141+
}

0 commit comments

Comments
 (0)