infra/jobs.tf (52 lines of code) (raw):

/** * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ # Job to apply server database updates resource "google_cloud_run_v2_job" "migrate" { name = var.random_suffix ? "migrate-${random_id.suffix.hex}" : "migrate" location = var.region labels = var.labels deletion_protection = false template { template { service_account = google_service_account.automation.email containers { image = local.server_image command = ["migrate"] env { name = "DJANGO_ENV" value_source { secret_key_ref { secret = google_secret_manager_secret.django_settings.secret_id version = "latest" } } } volume_mounts { name = "cloudsql" mount_path = "/cloudsql" } } volumes { name = "cloudsql" cloud_sql_instance { instances = [google_sql_database_instance.postgres.connection_name] } } } } depends_on = [ google_secret_manager_secret_version.django_settings ] } # Other jobs defined in postdeployment.tf