diff --git a/.changelog/2946.txt b/.changelog/2946.txt new file mode 100644 index 00000000000..307f2798104 --- /dev/null +++ b/.changelog/2946.txt @@ -0,0 +1,3 @@ +```release-note:bug +compute: fixed `google_compute_router_nat` timeout fields causing a diff when using a long-lived resource +``` diff --git a/google/resource_access_context_manager_access_level.go b/google/resource_access_context_manager_access_level.go index 0594dc0ad95..dfc2496102b 100644 --- a/google/resource_access_context_manager_access_level.go +++ b/google/resource_access_context_manager_access_level.go @@ -462,9 +462,10 @@ func flattenAccessContextManagerAccessLevelBasic(v interface{}, d *schema.Resour return []interface{}{transformed} } func flattenAccessContextManagerAccessLevelBasicCombiningFunction(v interface{}, d *schema.ResourceData) interface{} { - if v == nil || v.(string) == "" { + if v == nil || isEmptyValue(reflect.ValueOf(v)) { return "AND" } + return v } diff --git a/google/resource_access_context_manager_service_perimeter.go b/google/resource_access_context_manager_service_perimeter.go index 9f91c189d9a..990630d4e03 100644 --- a/google/resource_access_context_manager_service_perimeter.go +++ b/google/resource_access_context_manager_service_perimeter.go @@ -407,9 +407,10 @@ func flattenAccessContextManagerServicePerimeterUpdateTime(v interface{}, d *sch } func flattenAccessContextManagerServicePerimeterPerimeterType(v interface{}, d *schema.ResourceData) interface{} { - if v == nil || v.(string) == "" { + if v == nil || isEmptyValue(reflect.ValueOf(v)) { return "PERIMETER_TYPE_REGULAR" } + return v } diff --git a/google/resource_compute_address.go b/google/resource_compute_address.go index d627d470946..e8a831e1300 100644 --- a/google/resource_compute_address.go +++ b/google/resource_compute_address.go @@ -353,9 +353,10 @@ func flattenComputeAddressAddress(v interface{}, d *schema.ResourceData) interfa } func flattenComputeAddressAddressType(v interface{}, d *schema.ResourceData) interface{} { - if v == nil || v.(string) == "" { + if v == nil || isEmptyValue(reflect.ValueOf(v)) { return "EXTERNAL" } + return v } diff --git a/google/resource_compute_router_nat.go b/google/resource_compute_router_nat.go index fa8c82a4306..dd5c3d07275 100644 --- a/google/resource_compute_router_nat.go +++ b/google/resource_compute_router_nat.go @@ -721,42 +721,58 @@ func flattenComputeRouterNatMinPortsPerVm(v interface{}, d *schema.ResourceData) } func flattenComputeRouterNatUdpIdleTimeoutSec(v interface{}, d *schema.ResourceData) interface{} { + if v == nil || isEmptyValue(reflect.ValueOf(v)) { + return 30 + } // Handles the string fixed64 format if strVal, ok := v.(string); ok { if intVal, err := strconv.ParseInt(strVal, 10, 64); err == nil { return intVal } // let terraform core handle it if we can't convert the string to an int. } + return v } func flattenComputeRouterNatIcmpIdleTimeoutSec(v interface{}, d *schema.ResourceData) interface{} { + if v == nil || isEmptyValue(reflect.ValueOf(v)) { + return 30 + } // Handles the string fixed64 format if strVal, ok := v.(string); ok { if intVal, err := strconv.ParseInt(strVal, 10, 64); err == nil { return intVal } // let terraform core handle it if we can't convert the string to an int. } + return v } func flattenComputeRouterNatTcpEstablishedIdleTimeoutSec(v interface{}, d *schema.ResourceData) interface{} { + if v == nil || isEmptyValue(reflect.ValueOf(v)) { + return 1200 + } // Handles the string fixed64 format if strVal, ok := v.(string); ok { if intVal, err := strconv.ParseInt(strVal, 10, 64); err == nil { return intVal } // let terraform core handle it if we can't convert the string to an int. } + return v } func flattenComputeRouterNatTcpTransitoryIdleTimeoutSec(v interface{}, d *schema.ResourceData) interface{} { + if v == nil || isEmptyValue(reflect.ValueOf(v)) { + return 30 + } // Handles the string fixed64 format if strVal, ok := v.(string); ok { if intVal, err := strconv.ParseInt(strVal, 10, 64); err == nil { return intVal } // let terraform core handle it if we can't convert the string to an int. } + return v } diff --git a/google/resource_compute_target_https_proxy.go b/google/resource_compute_target_https_proxy.go index 9d3bce7c78b..3b7777f6b2e 100644 --- a/google/resource_compute_target_https_proxy.go +++ b/google/resource_compute_target_https_proxy.go @@ -457,6 +457,10 @@ func flattenComputeTargetHttpsProxyName(v interface{}, d *schema.ResourceData) i } func flattenComputeTargetHttpsProxyQuicOverride(v interface{}, d *schema.ResourceData) interface{} { + if v == nil || isEmptyValue(reflect.ValueOf(v)) { + return "NONE" + } + return v } diff --git a/google/resource_dns_managed_zone.go b/google/resource_dns_managed_zone.go index 67473e8a7f1..0a937382f63 100644 --- a/google/resource_dns_managed_zone.go +++ b/google/resource_dns_managed_zone.go @@ -544,9 +544,10 @@ func flattenDNSManagedZoneLabels(v interface{}, d *schema.ResourceData) interfac } func flattenDNSManagedZoneVisibility(v interface{}, d *schema.ResourceData) interface{} { - if v == nil || v.(string) == "" { + if v == nil || isEmptyValue(reflect.ValueOf(v)) { return "public" } + return v } diff --git a/google/resource_logging_metric.go b/google/resource_logging_metric.go index 87e6dab1f33..e69bff67fd8 100644 --- a/google/resource_logging_metric.go +++ b/google/resource_logging_metric.go @@ -586,9 +586,10 @@ func flattenLoggingMetricMetricDescriptorLabelsDescription(v interface{}, d *sch } func flattenLoggingMetricMetricDescriptorLabelsValueType(v interface{}, d *schema.ResourceData) interface{} { - if v == nil || v.(string) == "" { + if v == nil || isEmptyValue(reflect.ValueOf(v)) { return "STRING" } + return v }