From f8731a02f7240bee7ee5b42f330b32005c8c3d1b Mon Sep 17 00:00:00 2001 From: Sam Levenick Date: Fri, 8 Nov 2019 16:04:38 -0800 Subject: [PATCH] Send null logConfig if subnetwork is L7ILB (#2635) * Send null logConfig if subnetwork is L7ILB * Move subnet ilb check to only if logConfig unspecified --- products/compute/api.yaml | 3 ++- .../terraform/custom_expand/subnetwork_log_config.go.erb | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/products/compute/api.yaml b/products/compute/api.yaml index f82c473c2f19..b0c393da2c6d 100644 --- a/products/compute/api.yaml +++ b/products/compute/api.yaml @@ -9184,7 +9184,8 @@ objects: update_id: 'logConfig' description: | Denotes the logging options for the subnetwork flow logs. If logging is enabled - logs will be exported to Stackdriver. + logs will be exported to Stackdriver. This field cannot be set if the `purpose` of this + subnetwork is `INTERNAL_HTTPS_LOAD_BALANCER` properties: - !ruby/object:Api::Type::Enum name: 'aggregationInterval' diff --git a/templates/terraform/custom_expand/subnetwork_log_config.go.erb b/templates/terraform/custom_expand/subnetwork_log_config.go.erb index 6a1ca64370b5..a293f1b97562 100644 --- a/templates/terraform/custom_expand/subnetwork_log_config.go.erb +++ b/templates/terraform/custom_expand/subnetwork_log_config.go.erb @@ -16,10 +16,17 @@ func expand<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d T l := v.([]interface{}) transformed := make(map[string]interface{}) if len(l) == 0 || l[0] == nil { + purpose, ok := d.GetOkExists("purpose") + + if ok && purpose.(string) == "INTERNAL_HTTPS_LOAD_BALANCER" { + // Subnetworks for L7ILB do not accept any values for logConfig + return nil, nil + } // send enable = false to ensure logging is disabled if there is no config transformed["enable"] = false return transformed, nil } + raw := l[0] original := raw.(map[string]interface{})