diff --git a/locals.tf b/locals.tf index 16b2fed89b56aa85a4a68f8f4ef89e60348a0b31..4f9b1a7121881716ce47d9e6493fecab31352530 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 1cdbc6e7c3eae14d373b1fdb26fa3f530df41d44..3b4520865ea3f85f47fd4dfa5044177af908df37 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 73e4154a4bb834010b0a4e3fe2ca4dfa01417ba4..ca5142fd7a7ede58d58e689ffc346a24db0d8d83 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." +}