Skip to content

Commit 0541c06

Browse files
committed
wip for release
1 parent 8da8bf8 commit 0541c06

15 files changed

Lines changed: 817 additions & 50 deletions

File tree

deploy.sh

Lines changed: 618 additions & 0 deletions
Large diffs are not rendered by default.

frontend/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
!environment.ts
66
!environment.prod.ts
77
proxy.conf.json
8+
public/assets/config.json
9+
810

911
# Compiled output
1012
/dist
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"production": true,
3+
"isLocal": false,
4+
"backendURL": "https://cstudio-backend-dev.mydomain.com/api",
5+
"GOOGLE_CLIENT_ID": "your-oauth-web-client-id-here.apps.googleusercontent.com",
6+
"firebase": {
7+
"apiKey": "your-firebase-api-key",
8+
"authDomain": "your-firebase-auth-domain.firebaseapp.com",
9+
"projectId": "your-firebase-project-id",
10+
"storageBucket": "your-firebase-storage-bucket.appspot.com",
11+
"messagingSenderId": "your-firebase-messaging-sender-id",
12+
"appId": "your-firebase-web-app-id",
13+
"measurementId": "your-google-analytics-measurement-id"
14+
}
15+
}

infrastructure/.terraform.lock.hcl

Lines changed: 63 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

infrastructure/app.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module "compute" {
2121
vpc_subnet_name = module.network.cloud_run_subnet_name
2222
database_ip = module.database.private_ip_address
2323
image_url = "${module.artifact.repository_url}/${var.backend_image_name}:${var.backend_image_tag}"
24-
24+
2525
# References the list keys to configure secret environment block mappings
26-
secret_ids = var.application_secrets
26+
secret_ids = var.application_secrets
2727
}

infrastructure/data.tf

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ module "database" {
66
region = var.region
77
resource_prefix = var.resource_prefix
88
environment = var.environment
9-
10-
vpc_id = module.network.network_id
9+
10+
vpc_id = module.network.network_id
1111

1212
# Guardrail: Explicitly wait for Private Services Access peering to
1313
# finish provisioning before kicking off database creation.
@@ -54,11 +54,15 @@ resource "google_secret_manager_secret" "app_secrets" {
5454
secret_id = each.key
5555

5656
replication {
57-
automatic = true
57+
user_managed {
58+
replicas {
59+
location = var.region # restricted to the infra region
60+
}
61+
}
5862
}
5963

6064
labels = merge(var.labels, {
61-
component = "security"
65+
component = "security"
6266
managed_by = "terraform"
6367
})
6468
}
@@ -70,7 +74,7 @@ resource "google_secret_manager_secret_iam_member" "backend_accessor" {
7074
project = google_secret_manager_secret.app_secrets[each.key].project
7175
secret_id = google_secret_manager_secret.app_secrets[each.key].secret_id
7276
role = "roles/secretmanager.secretAccessor"
73-
77+
7478
# References backend module's service account output dynamically
75-
member = "serviceAccount:${module.compute.service_account_email}"
79+
member = "serviceAccount:${module.compute.service_account_email}"
7680
}

infrastructure/hosting.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
# Creates the Firebase Hosting site to deploy to
33
resource "google_firebase_hosting_site" "frontend" {
44
provider = google-beta
5-
project = var.firebase_project_id
5+
project = var.project_id
66
site_id = var.firebase_site_id
77
}
88

99
# Conditionally map the Custom Domain if provided
1010
resource "google_firebase_hosting_custom_domain" "custom_domain" {
1111
provider = google-beta
1212
# Evaluates to 1 if a domain string is provided, 0 if left blank
13-
count = var.custom_domain != "" ? 1 : 0
13+
count = var.custom_domain != "" ? 1 : 0
1414

1515
project = var.project_id
1616
site_id = google_firebase_hosting_site.frontend.site_id

infrastructure/modules/artifact/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ resource "google_artifact_registry_repository" "ghcr_proxy" {
55
repository_id = "${var.resource_prefix}-${var.environment}-${var.repository_id}"
66
description = "Regional proxy for GHCR with vulnerability scanning"
77
format = "DOCKER"
8-
8+
99
# Remote Repository Mode
1010
mode = "REMOTE_REPOSITORY"
11-
11+
1212
remote_repository_config {
1313
description = "Proxy for GitHub Container Registry"
1414
docker_repository {
@@ -24,7 +24,7 @@ resource "google_artifact_registry_repository" "ghcr_proxy" {
2424
vulnerability_scanning_config {
2525
enablement_config = "INHERITED" # Inherits project-level scan settings
2626
}
27-
27+
2828
# Cost Guardrail: Automatically purge cached layers unaccessed for 30 days
2929
cleanup_policies {
3030
id = "delete-stale-cache"

infrastructure/modules/compute/main.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
locals {
216

317
# The format requires: REGION-docker.pkg.dev / PROJECT_ID / PROXY_REPO_ID / GH_ORG / GH_REPO / IMAGE_NAME

infrastructure/modules/database/main.tf

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ resource "random_id" "db_name_suffix" {
1313
resource "google_secret_manager_secret" "db_secret" {
1414
secret_id = "${var.resource_prefix}-${var.environment}-db-password"
1515
project = var.project_id
16-
16+
1717
replication {
1818
user_managed {
1919
replicas {
@@ -25,41 +25,41 @@ resource "google_secret_manager_secret" "db_secret" {
2525

2626
resource "google_secret_manager_secret_version" "db_secret_version" {
2727
secret = google_secret_manager_secret.db_secret.id
28-
28+
2929
# Using a write-only argument prevents the password
3030
# from being captured in the terraform.tfstate file.
3131
secret_data_wo = ephemeral.random_password.db_pass.result
3232
}
3333

3434
resource "google_sql_database_instance" "default" {
3535
name = "${var.resource_prefix}-${var.environment}-db-${random_id.db_name_suffix.hex}"
36-
database_version = var.database_version
36+
database_version = var.database_version
3737
region = var.region
3838
project = var.project_id
3939

4040
# Ensure networking PSA is established before instance creation
4141
depends_on = [var.psa_connection_dependency]
4242

4343
settings {
44-
tier = var.db_tier # "db-perf-optimized-N-2"
44+
tier = var.db_tier # "db-perf-optimized-N-2"
4545
availability_type = var.db_availability_type
46-
46+
4747
# Enable IAM Authentication for better security
4848
database_flags {
4949
name = "cloudsql.iam_authentication"
5050
value = "on"
5151
}
5252

5353
# --- Storage Flexibility ---
54-
disk_type = "PD_SSD"
55-
disk_size = var.initial_disk_size
56-
disk_autoresize = true # Allows growth as needed
57-
disk_autoresize_limit = var.max_disk_size # Prevents unlimited expansion/billing surprises
54+
disk_type = "PD_SSD"
55+
disk_size = var.initial_disk_size
56+
disk_autoresize = true # Allows growth as needed
57+
disk_autoresize_limit = var.max_disk_size # Prevents unlimited expansion/billing surprises
5858

5959
backup_configuration {
6060
enabled = true
6161
point_in_time_recovery_enabled = true
62-
location = var.region
62+
location = var.region
6363
}
6464

6565
# --- Network Isolation ---
@@ -72,18 +72,18 @@ resource "google_sql_database_instance" "default" {
7272
# --- Enterprise Metadata ---
7373
# Merges common labels (from root) with module-specific labels
7474
user_labels = merge(var.labels, {
75-
component = "database"
75+
component = "database"
7676
managed_by = "terraform"
77-
region = var.region
77+
region = var.region
7878
})
79-
79+
8080
}
81-
81+
8282
deletion_protection = var.deletion_protection
8383

8484
lifecycle {
8585
# Prevent accidental destruction of production data
86-
prevent_destroy = false
86+
prevent_destroy = false
8787
# Ignore disk_size changes if auto-resize has grown the disk beyond the TF value
8888
ignore_changes = [settings[0].disk_size]
8989
}
@@ -99,9 +99,9 @@ resource "google_sql_user" "app_user" {
9999
name = var.db_user
100100
instance = google_sql_database_instance.default.name
101101
project = var.project_id
102-
102+
103103
# We read the ephemeral value while creating the DB user,
104104
# keeping the DB state clean of plaintext passwords.
105-
password_wo = ephemeral.random_password.db_pass.result
105+
password_wo = ephemeral.random_password.db_pass.result
106106
password_wo_version = var.db_password_version
107107
}

0 commit comments

Comments
 (0)