diff --git a/google/compute_backend_service.go b/google/compute_backend_service.go index a3f194c3b..6d53e1bda 100644 --- a/google/compute_backend_service.go +++ b/google/compute_backend_service.go @@ -19,6 +19,7 @@ import ( "fmt" "log" "reflect" + "strings" "github.com/hashicorp/terraform-plugin-sdk/helper/hashcode" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -317,6 +318,24 @@ func resourceComputeBackendServiceEncoder(d TerraformResourceData, meta interfac obj["iap"] = iap } + backendsRaw, ok := obj["backends"] + if !ok { + return obj, nil + } + backends := backendsRaw.([]interface{}) + for _, backendRaw := range backends { + backend := backendRaw.(map[string]interface{}) + backendGroup, ok := backend["group"] + if !ok { + continue + } + if strings.Contains(backendGroup.(string), "global/networkEndpointGroups") { + // Remove `max_utilization` from any backend that belongs to a global NEG. This field + // has a default value and causes API validation errors + backend["maxUtilization"] = nil + } + } + return obj, nil }