From e1070f29154ace578ec9093f8735fdf5f798add1 Mon Sep 17 00:00:00 2001 From: Aurora Del Rio Date: Tue, 12 Dec 2023 11:20:04 +0000 Subject: [PATCH] cloud build location var --- gcp/cloud-cloudbuild-trigger/main.tf | 1 + gcp/cloud-cloudbuild-trigger/variables.tf | 6 ++++++ gcp/cloud-function-gen2/main.tf | 1 + gcp/cloud-function-gen2/variables.tf | 6 ++++++ gcp/cloud-run-v2/main.tf | 1 + gcp/cloud-run-v2/variables.tf | 5 +++++ 6 files changed, 20 insertions(+) diff --git a/gcp/cloud-cloudbuild-trigger/main.tf b/gcp/cloud-cloudbuild-trigger/main.tf index 95fffc9..cf1f347 100644 --- a/gcp/cloud-cloudbuild-trigger/main.tf +++ b/gcp/cloud-cloudbuild-trigger/main.tf @@ -2,6 +2,7 @@ resource "google_cloudbuild_trigger" "trigger_main" { description = var.description tags = var.tags name = var.name + location = var.location github { owner = var.repository_owner name = var.repository_name diff --git a/gcp/cloud-cloudbuild-trigger/variables.tf b/gcp/cloud-cloudbuild-trigger/variables.tf index 8b8e7b2..e9d24f3 100644 --- a/gcp/cloud-cloudbuild-trigger/variables.tf +++ b/gcp/cloud-cloudbuild-trigger/variables.tf @@ -10,6 +10,12 @@ variable "description" { description = "The description of the Cloud Build trigger." } +variable "location" { + type = string + default = null + description = "The location of the Cloud Build trigger. If not specify, the default location will be global." +} + # Filename of the build configuration variable "filename" { type = string diff --git a/gcp/cloud-function-gen2/main.tf b/gcp/cloud-function-gen2/main.tf index 2306c9b..b5b9e65 100644 --- a/gcp/cloud-function-gen2/main.tf +++ b/gcp/cloud-function-gen2/main.tf @@ -177,6 +177,7 @@ module "trigger_provision" { name = "function-${var.function_name}-provision" description = "Provision ${var.function_name} Service (CI/CD)" source = "../cloud-cloudbuild-trigger" + location = var.location filename = var.function_path == "" ? "services/${var.service_name}/functions/${var.function_name}/cloudbuild.yaml" : "${var.function_path}/cloudbuild.yaml" include = var.function_path == "" ? ["services/${var.service_name}/functions/${var.function_name}/**"] : ["${var.function_path}/**"] tags = ["function"] diff --git a/gcp/cloud-function-gen2/variables.tf b/gcp/cloud-function-gen2/variables.tf index e5c5470..41ac233 100644 --- a/gcp/cloud-function-gen2/variables.tf +++ b/gcp/cloud-function-gen2/variables.tf @@ -137,6 +137,12 @@ variable "project_id" { type = string } +variable "location" { + description = "Cloud build trigger location. If not specified, the default location will be global." + type = string + default = null +} + variable "trigger_config" { description = "Configuration for the Cloud Build Trigger" type = object({ diff --git a/gcp/cloud-run-v2/main.tf b/gcp/cloud-run-v2/main.tf index 31accb2..1bee04b 100644 --- a/gcp/cloud-run-v2/main.tf +++ b/gcp/cloud-run-v2/main.tf @@ -265,6 +265,7 @@ module "trigger_provision" { source = "../cloud-cloudbuild-trigger" name = "service-${var.name}-provision" repository_name = var.repository_name + location = var.location description = "Provision ${var.name} Service (CI/CD)" filename = "${var.service_path}/cloudbuild.yaml" include = concat(["${var.service_path}/**"], var.dependencies) diff --git a/gcp/cloud-run-v2/variables.tf b/gcp/cloud-run-v2/variables.tf index 4471960..8fb5367 100644 --- a/gcp/cloud-run-v2/variables.tf +++ b/gcp/cloud-run-v2/variables.tf @@ -189,6 +189,11 @@ variable "service_path" { type = string } +variable "location" { + description = "Cloud build trigger location. If not specified, the default location will be global." + type = string + default = null +} variable "trigger_config" { description = "Configuration for the Cloud Build Trigger"