From e4a66071d8eccfad02616ac28eb9d645150604a6 Mon Sep 17 00:00:00 2001 From: Ash Davies <1892070+ashdavies@users.noreply.github.com> Date: Sun, 19 Jan 2025 20:48:06 +0100 Subject: [PATCH] Provide artifact endpoint definitions (#1448) Co-authored-by: Ashley Davies --- terraform/modules.tf | 14 +++-- .../modules/google/cloud-run-build/main.tf | 13 +++-- .../google/cloud-run-build/variables.tf | 10 ++-- .../modules/google/cloud-run-endpoint/main.tf | 57 ++++++++++--------- .../scripts/gcloud_build_image | 0 .../google/cloud-run-endpoint/variables.tf | 18 +++--- 6 files changed, 64 insertions(+), 48 deletions(-) mode change 100644 => 100755 terraform/modules/google/cloud-run-endpoint/scripts/gcloud_build_image diff --git a/terraform/modules.tf b/terraform/modules.tf index 43d0d03d7..ea0ed8348 100644 --- a/terraform/modules.tf +++ b/terraform/modules.tf @@ -8,18 +8,20 @@ module "api-gateway" { } module "cloud-run-build" { - docker_image = "${var.project_region}-docker.pkg.dev/${var.project_id}/cloud-run-source-deploy/api.ashdavies.dev" - source = "./modules/google/cloud-run-build" - service_name = "playground-service" - location = var.project_region - project = var.project_id + image_name = "api.ashdavies.dev" + location = var.project_region + project = var.project_id + repository_id = "cloud-run-source-deploy" + service_name = "playground-service" + source = "./modules/google/cloud-run-build" } # module.cloud-run-endpoint is deprecated module "cloud-run-endpoint" { source = "./modules/google/cloud-run-endpoint" config_id = module.cloud-run-endpoint.config_id - container_image = "${var.project_region}-docker.pkg.dev/${var.project_id}/endpoints-release/endpoints-runtime-serverless:latest" + image_name = "endpoints-runtime-serverless" + repository_id = "endpoints-release" endpoint_name = "api.ashdavies.dev" image_repository = "${var.project_region}-docker.pkg.dev/${var.project_id}/endpoints-release" location = var.project_region diff --git a/terraform/modules/google/cloud-run-build/main.tf b/terraform/modules/google/cloud-run-build/main.tf index 6904b7ebb..92b41d6e5 100644 --- a/terraform/modules/google/cloud-run-build/main.tf +++ b/terraform/modules/google/cloud-run-build/main.tf @@ -1,12 +1,11 @@ resource "google_cloud_run_service" "main" { - name = var.service_name - location = var.location - autogenerate_revision_name = true + name = var.service_name + location = var.location template { spec { containers { - image = "${var.docker_image}:latest" + image = data.google_artifact_registry_docker_image.main.self_link } } } @@ -16,3 +15,9 @@ resource "google_cloud_run_service" "main" { percent = var.percent } } + +data "google_artifact_registry_docker_image" "main" { + location = var.location + repository_id = var.repository_id + image_name = var.image_name +} diff --git a/terraform/modules/google/cloud-run-build/variables.tf b/terraform/modules/google/cloud-run-build/variables.tf index 8ae761ed2..ed957e249 100644 --- a/terraform/modules/google/cloud-run-build/variables.tf +++ b/terraform/modules/google/cloud-run-build/variables.tf @@ -1,8 +1,6 @@ -variable "docker_image" { +variable "image_name" { description = <