From 9c9430f38ce0de0d8a268163c5225761e12d0a6f Mon Sep 17 00:00:00 2001 From: The Magician Date: Thu, 13 Aug 2020 14:03:06 -0700 Subject: [PATCH] Send empty privateVisibilityConfig network array (#3865) (#7022) Signed-off-by: Modular Magician --- .changelog/3865.txt | 3 +++ google/resource_dns_managed_zone.go | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 .changelog/3865.txt diff --git a/.changelog/3865.txt b/.changelog/3865.txt new file mode 100644 index 00000000000..686b59c3f9e --- /dev/null +++ b/.changelog/3865.txt @@ -0,0 +1,3 @@ +```release-note:bug +dns: fixed an issue where `google_dns_managed_zone` would not remove `private_visibility_config` on updates +``` diff --git a/google/resource_dns_managed_zone.go b/google/resource_dns_managed_zone.go index b9c93ae7ad3..c7dc2b2fe78 100644 --- a/google/resource_dns_managed_zone.go +++ b/google/resource_dns_managed_zone.go @@ -344,7 +344,7 @@ func resourceDNSManagedZoneCreate(d *schema.ResourceData, meta interface{}) erro privateVisibilityConfigProp, err := expandDNSManagedZonePrivateVisibilityConfig(d.Get("private_visibility_config"), d, config) if err != nil { return err - } else if v, ok := d.GetOkExists("private_visibility_config"); !isEmptyValue(reflect.ValueOf(privateVisibilityConfigProp)) && (ok || !reflect.DeepEqual(v, privateVisibilityConfigProp)) { + } else if v, ok := d.GetOkExists("private_visibility_config"); ok || !reflect.DeepEqual(v, privateVisibilityConfigProp) { obj["privateVisibilityConfig"] = privateVisibilityConfigProp } forwardingConfigProp, err := expandDNSManagedZoneForwardingConfig(d.Get("forwarding_config"), d, config) @@ -472,7 +472,7 @@ func resourceDNSManagedZoneUpdate(d *schema.ResourceData, meta interface{}) erro privateVisibilityConfigProp, err := expandDNSManagedZonePrivateVisibilityConfig(d.Get("private_visibility_config"), d, config) if err != nil { return err - } else if v, ok := d.GetOkExists("private_visibility_config"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, privateVisibilityConfigProp)) { + } else if v, ok := d.GetOkExists("private_visibility_config"); ok || !reflect.DeepEqual(v, privateVisibilityConfigProp) { obj["privateVisibilityConfig"] = privateVisibilityConfigProp } forwardingConfigProp, err := expandDNSManagedZoneForwardingConfig(d.Get("forwarding_config"), d, config) @@ -924,7 +924,11 @@ func expandDNSManagedZoneVisibility(v interface{}, d TerraformResourceData, conf func expandDNSManagedZonePrivateVisibilityConfig(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { - return nil, nil + // The API won't remove the the field unless an empty network array is sent. + transformed := make(map[string]interface{}) + emptyNetwork := make([]interface{}, 0) + transformed["networks"] = emptyNetwork + return transformed, nil } raw := l[0] original := raw.(map[string]interface{})