From 83a730ef5cf6d8c3eebe480f50986f81b7fb4426 Mon Sep 17 00:00:00 2001 From: gregor <gregor.schulz@holi.social> Date: Thu, 20 Mar 2025 11:20:54 +0100 Subject: [PATCH] forward envs in terraform infra --- terraform/environments/deployment.tf | 14 +++++++++++--- terraform/environments/init.tf | 9 +++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/terraform/environments/deployment.tf b/terraform/environments/deployment.tf index 8cdb144..c5dd942 100644 --- a/terraform/environments/deployment.tf +++ b/terraform/environments/deployment.tf @@ -30,8 +30,8 @@ variable "image_tag" { } resource "google_cloud_run_service" "events" { - project = data.terraform_remote_state.holi_infra_state.outputs.shared_project_id - name = random_id.main.hex + project = data.terraform_remote_state.holi_infra_state.outputs.shared_project_id + name = random_id.main.hex location = local.default_region # https://github.com/hashicorp/terraform-provider-google/issues/5898 autogenerate_revision_name = true @@ -63,6 +63,14 @@ resource "google_cloud_run_service" "events" { name = "ENVIRONMENT" value = local.environment } + env { + name = "IMAGE_PROXY_BASE_URL" + value = local.environment == "production" ? "https://images.holi.social" : "https://dev-images.holi.social" + } + env { + name = "GEO_API_ENDPOINT_URL" + value = data.terraform_remote_state.holi_geo_api_environments_state.outputs.api_endpoint_url + } resources { limits = { # cpu can only be scaled down to 1000m as long as container_concurrency is set to != 1 @@ -80,7 +88,7 @@ resource "google_cloud_run_service" "events" { # template annotations: https://cloud.google.com/run/docs/reference/rpc/google.cloud.run.v1#revisiontemplate metadata { annotations = { - "autoscaling.knative.dev/minScale" = local.environment == "production" ? "1" : "0" + "autoscaling.knative.dev/minScale" = local.environment == "production" ? "1" : "0" "autoscaling.knative.dev/maxScale" = local.environment == "production" ? "2" : "1" # Use the VPC Connector "run.googleapis.com/vpc-access-connector" = data.terraform_remote_state.holi_infra_state.outputs.vpc_access_connector_name diff --git a/terraform/environments/init.tf b/terraform/environments/init.tf index b5b2ede..c391bb4 100644 --- a/terraform/environments/init.tf +++ b/terraform/environments/init.tf @@ -21,6 +21,15 @@ data "terraform_remote_state" "holi_events_common_state" { } } +data "terraform_remote_state" "holi_geo_api_environments_state" { + backend = "gcs" + workspace = terraform.workspace == "production" ? "production" : "staging" + config = { + bucket = "holi-shared-terraform-state" + prefix = "geo-api-environments" + } +} + # provider google including beta features provider "google" { region = local.default_region -- GitLab