Add Global Load Balancer in front of Cloud Run

This commit is contained in:
Julio Diez
2023-01-25 10:17:46 +01:00
parent aca604e085
commit 6c8c033c76
2 changed files with 47 additions and 2 deletions

View File

@@ -1,7 +1,8 @@
module "cloud_run" {
source = "../../../modules/cloud-run"
project_id = var.project_id
name = "hello"
name = var.run_svc_name
region = var.region
containers = [{
image = var.image
options = null
@@ -13,3 +14,29 @@ module "cloud_run" {
"roles/run.invoker" = ["allUsers"]
}
}
module "glb" {
source = "../../../modules/net-glb"
count = var.glb_create ? 1 : 0
project_id = var.project_id
name = "glb"
backend_service_configs = {
default = {
backends = [
{ backend = "neg-0" }
]
health_checks = []
}
}
health_check_configs = {}
neg_configs = {
neg-0 = {
cloudrun = {
region = var.region
target_service = {
name = var.run_svc_name
}
}
}
}
}

View File

@@ -3,7 +3,25 @@ variable "project_id" {
type = string
}
variable "region" {
description = "Cloud region where resource will be deployed"
type = string
default = "europe-west1"
}
variable "run_svc_name" {
description = "Cloud Run service name"
type = string
default = "hello"
}
variable "image" {
description = "Container image to deploy"
type = string
}
}
variable "glb_create" {
description = "Create a Global Load Balancer in front of the Cloud Run service"
type = bool
default = false
}