terraform-google-modules / terraform-google-lb-http

Creates a global HTTP load balancer for Compute Engine by using forwarding rules

Home Page:https://registry.terraform.io/modules/terraform-google-modules/lb-http/google

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't set cache mode for serverless NEG to FORCE_CACHE_ALL

douglasward opened this issue · comments

TL;DR

Changing the cache mode for a serverless NEG backend from CACHE_ALL_STATIC to FORCE_CACHE_ALL fails with

Invalid value for field 'resource.cdnPolicy.maxTtl': '10800'. max_ttl must be specified with CACHE_ALL_STATIC cache_mode only.

Expected behavior

If maxTtl isn't set or it is set to null then it should be removed from the cdn policy settings and allow the change to succeed.

Observed behavior

the current maxTtl value isn't removed / default is sent

Terraform Configuration

module "lb-http" {
  source  = "GoogleCloudPlatform/lb-http/google//modules/serverless_negs"
  version = "~> 11.1.0"
  name    = "production-lb"
  project = "xxx"

  foo-bar = {
    description                     = null
    port_name                       = "http"
    protocol                        = "HTTP"
    session_affinity                = "NONE"
    timeout_sec                     = 30
    connection_draining_timeout_sec = 0
    load_balancing_scheme           = "EXTERNAL"
    enable_cdn                      = true
    cdn_policy = {
      cache_mode  = "FORCE_CACHE_ALL"
      default_ttl = 3600
      client_ttl  = 7200
      cache_key_policy = {
        include_host         = true
        include_protocol     = true
        include_query_string = true
      }
    }
  }
}

Terraform Version

Terraform v1.6.1
on darwin_arm64
+ provider registry.terraform.io/hashicorp/google v5.32.0
+ provider registry.terraform.io/hashicorp/google-beta v5.32.0
+ provider registry.terraform.io/hashicorp/random v3.6.2

Additional information

This issue appears to already have been addressed here hashicorp/terraform-provider-google#16935 but it still isn't working for me