litellm/terraform/litellm/gcp/bootstrap.tf
devin-ai-integration[bot] b290dd410e
feat(terraform/gcp): dependencies-only mode and bring-your-own-network for GKE (#39695)
* feat(terraform/gcp): add dependencies-only mode

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(terraform/gcp): review fixes for dependencies-only mode

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: yassin <yassin@berri.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-05 12:22:52 -07:00

45 lines
1.4 KiB
HCL

# Auto-runs the prisma schema migration as part of `terraform apply`. Mirrors
# the AWS stack's terraform_data.migration in spirit. Cloud SQL doesn't need a
# separate user-bootstrap step because google_sql_user.app already creates the
# application user — so the only post-cluster work is the migration.
#
# Gateway/backend Cloud Run services depend on this resource (in cloudrun.tf)
# so they don't go live until the schema is in place.
#
# Triggers:
# - re-runs if the migrations image changes (new release ships new prisma
# migration files).
# - re-runs if the migration job is recreated.
#
# Requires `gcloud` on the machine running terraform, with user creds live
# enough to invoke Cloud Run admin APIs (`gcloud auth login`).
resource "terraform_data" "migration" {
count = var.create_runtime ? 1 : 0
triggers_replace = {
job_id = google_cloud_run_v2_job.migrations[0].id
job_image = local.migrations_image
}
provisioner "local-exec" {
interpreter = ["bash", "-c"]
environment = {
JOB = google_cloud_run_v2_job.migrations[0].name
REGION = var.region
PROJECT = var.project_id
}
command = <<-EOT
set -euo pipefail
gcloud run jobs execute "$JOB" \
--region "$REGION" \
--project "$PROJECT" \
--wait
EOT
}
depends_on = [
google_cloud_run_v2_job.migrations,
google_sql_user.app,
]
}