From 60946f5cbf836812b53ca0f42cafe3d4340cf463 Mon Sep 17 00:00:00 2001 From: Monty Dawson <wgd23@cam.ac.uk> Date: Wed, 27 Jan 2021 09:17:32 +0000 Subject: [PATCH] Refactor enabling beta launch stage to local with variable override --- locals.tf | 6 ++++++ main.tf | 2 +- variables.tf | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/locals.tf b/locals.tf index 16b2fed..4f9b1a7 100644 --- a/locals.tf +++ b/locals.tf @@ -6,4 +6,10 @@ locals { # Should a DNS domain mapping be created? domain_mapping_present = var.dns_name != "" + + # Do we need to enable the 'beta' launch stage - only required if certain beta + # functionality is being used, or if `enable_beta_launch_stage` is set downstream + enable_beta_launch_stage = ( + var.enable_beta_launch_stage || var.allowed_ingress != "all" || var.min_scale > 0 + ) } diff --git a/main.tf b/main.tf index 1cdbc6e..3b45208 100644 --- a/main.tf +++ b/main.tf @@ -38,7 +38,7 @@ resource "google_cloud_run_service" "webapp" { }, # Add the beta launch stage if required. - var.allowed_ingress != "all" || var.min_scale > 0 ? { + local.enable_beta_launch_stage ? { # Required to be able to set ingress type. "run.googleapis.com/launch-stage" : "BETA", } : {}, diff --git a/variables.tf b/variables.tf index 73e4154..ca5142f 100644 --- a/variables.tf +++ b/variables.tf @@ -163,3 +163,8 @@ variable "template_annotations" { template. EOL } + +variable "enable_beta_launch_stage" { + default = false + description = "Force use of the 'BETA' launch stage for the service." +} -- GitLab