diff --git a/.changelog/3499.txt b/.changelog/3499.txt new file mode 100644 index 0000000000..78ec64c290 --- /dev/null +++ b/.changelog/3499.txt @@ -0,0 +1,3 @@ +```release-note:bug +compute: fixed error where plan would error if `google_compute_region_disk_resource_policy_attachment` had been deleted outside of terraform. +``` diff --git a/google-beta/resource_access_context_manager_service_perimeter_resource.go b/google-beta/resource_access_context_manager_service_perimeter_resource.go index 898bbd2277..bd1a1d7df7 100644 --- a/google-beta/resource_access_context_manager_service_perimeter_resource.go +++ b/google-beta/resource_access_context_manager_service_perimeter_resource.go @@ -252,9 +252,7 @@ func flattenNestedAccessContextManagerServicePerimeterResource(d *schema.Resourc v, ok = res["resources"] if !ok || v == nil { - // It's possible that there is only one of these resources and - // that res represents that resource. - v = res + return nil, nil } switch v.(type) { diff --git a/google-beta/resource_big_query_dataset_access.go b/google-beta/resource_big_query_dataset_access.go index c572574099..ceff3d8b90 100644 --- a/google-beta/resource_big_query_dataset_access.go +++ b/google-beta/resource_big_query_dataset_access.go @@ -491,9 +491,7 @@ func flattenNestedBigQueryDatasetAccess(d *schema.ResourceData, meta interface{} v, ok = res["access"] if !ok || v == nil { - // It's possible that there is only one of these resources and - // that res represents that resource. - v = res + return nil, nil } switch v.(type) { diff --git a/google-beta/resource_compute_backend_bucket_signed_url_key.go b/google-beta/resource_compute_backend_bucket_signed_url_key.go index 592e0758c9..052ddfba91 100644 --- a/google-beta/resource_compute_backend_bucket_signed_url_key.go +++ b/google-beta/resource_compute_backend_bucket_signed_url_key.go @@ -246,9 +246,7 @@ func flattenNestedComputeBackendBucketSignedUrlKey(d *schema.ResourceData, meta v, ok = res["signedUrlKeyNames"] if !ok || v == nil { - // It's possible that there is only one of these resources and - // that res represents that resource. - v = res + return nil, nil } switch v.(type) { diff --git a/google-beta/resource_compute_backend_service_signed_url_key.go b/google-beta/resource_compute_backend_service_signed_url_key.go index 9638ed87b9..5e08363029 100644 --- a/google-beta/resource_compute_backend_service_signed_url_key.go +++ b/google-beta/resource_compute_backend_service_signed_url_key.go @@ -246,9 +246,7 @@ func flattenNestedComputeBackendServiceSignedUrlKey(d *schema.ResourceData, meta v, ok = res["signedUrlKeyNames"] if !ok || v == nil { - // It's possible that there is only one of these resources and - // that res represents that resource. - v = res + return nil, nil } switch v.(type) { diff --git a/google-beta/resource_compute_disk_resource_policy_attachment.go b/google-beta/resource_compute_disk_resource_policy_attachment.go index d0cd14d5ad..c3c387cd02 100644 --- a/google-beta/resource_compute_disk_resource_policy_attachment.go +++ b/google-beta/resource_compute_disk_resource_policy_attachment.go @@ -296,9 +296,7 @@ func flattenNestedComputeDiskResourcePolicyAttachment(d *schema.ResourceData, me v, ok = res["resourcePolicies"] if !ok || v == nil { - // It's possible that there is only one of these resources and - // that res represents that resource. - v = res + return nil, nil } switch v.(type) { diff --git a/google-beta/resource_compute_global_network_endpoint.go b/google-beta/resource_compute_global_network_endpoint.go index 8fd69c67d3..94b90b2961 100644 --- a/google-beta/resource_compute_global_network_endpoint.go +++ b/google-beta/resource_compute_global_network_endpoint.go @@ -339,9 +339,7 @@ func flattenNestedComputeGlobalNetworkEndpoint(d *schema.ResourceData, meta inte v, ok = res["items"] if !ok || v == nil { - // It's possible that there is only one of these resources and - // that res represents that resource. - v = res + return nil, nil } switch v.(type) { diff --git a/google-beta/resource_compute_instance_group_named_port.go b/google-beta/resource_compute_instance_group_named_port.go index 1ff44e74e8..1edf750f61 100644 --- a/google-beta/resource_compute_instance_group_named_port.go +++ b/google-beta/resource_compute_instance_group_named_port.go @@ -308,9 +308,7 @@ func flattenNestedComputeInstanceGroupNamedPort(d *schema.ResourceData, meta int v, ok = res["namedPorts"] if !ok || v == nil { - // It's possible that there is only one of these resources and - // that res represents that resource. - v = res + return nil, nil } switch v.(type) { diff --git a/google-beta/resource_compute_network_endpoint.go b/google-beta/resource_compute_network_endpoint.go index bc8431e30b..a2521c7425 100644 --- a/google-beta/resource_compute_network_endpoint.go +++ b/google-beta/resource_compute_network_endpoint.go @@ -347,9 +347,7 @@ func flattenNestedComputeNetworkEndpoint(d *schema.ResourceData, meta interface{ v, ok = res["items"] if !ok || v == nil { - // It's possible that there is only one of these resources and - // that res represents that resource. - v = res + return nil, nil } switch v.(type) { diff --git a/google-beta/resource_compute_network_peering_routes_config.go b/google-beta/resource_compute_network_peering_routes_config.go index f35ac6fe93..b96697eda5 100644 --- a/google-beta/resource_compute_network_peering_routes_config.go +++ b/google-beta/resource_compute_network_peering_routes_config.go @@ -320,9 +320,7 @@ func flattenNestedComputeNetworkPeeringRoutesConfig(d *schema.ResourceData, meta v, ok = res["peerings"] if !ok || v == nil { - // It's possible that there is only one of these resources and - // that res represents that resource. - v = res + return nil, nil } switch v.(type) { diff --git a/google-beta/resource_compute_per_instance_config.go b/google-beta/resource_compute_per_instance_config.go index 2bf2b291e0..b2d692bbb5 100644 --- a/google-beta/resource_compute_per_instance_config.go +++ b/google-beta/resource_compute_per_instance_config.go @@ -559,9 +559,7 @@ func flattenNestedComputePerInstanceConfig(d *schema.ResourceData, meta interfac v, ok = res["items"] if !ok || v == nil { - // It's possible that there is only one of these resources and - // that res represents that resource. - v = res + return nil, nil } switch v.(type) { diff --git a/google-beta/resource_compute_region_disk_resource_policy_attachment.go b/google-beta/resource_compute_region_disk_resource_policy_attachment.go index 656657009a..43237e18e8 100644 --- a/google-beta/resource_compute_region_disk_resource_policy_attachment.go +++ b/google-beta/resource_compute_region_disk_resource_policy_attachment.go @@ -280,9 +280,7 @@ func flattenNestedComputeRegionDiskResourcePolicyAttachment(d *schema.ResourceDa v, ok = res["resourcePolicies"] if !ok || v == nil { - // It's possible that there is only one of these resources and - // that res represents that resource. - v = res + return nil, nil } switch v.(type) { diff --git a/google-beta/resource_compute_region_per_instance_config.go b/google-beta/resource_compute_region_per_instance_config.go index 6557499ef1..6ffff09b08 100644 --- a/google-beta/resource_compute_region_per_instance_config.go +++ b/google-beta/resource_compute_region_per_instance_config.go @@ -559,9 +559,7 @@ func flattenNestedComputeRegionPerInstanceConfig(d *schema.ResourceData, meta in v, ok = res["items"] if !ok || v == nil { - // It's possible that there is only one of these resources and - // that res represents that resource. - v = res + return nil, nil } switch v.(type) { diff --git a/google-beta/resource_compute_router_bgp_peer.go b/google-beta/resource_compute_router_bgp_peer.go index b2d0ccb948..15ad4b4088 100644 --- a/google-beta/resource_compute_router_bgp_peer.go +++ b/google-beta/resource_compute_router_bgp_peer.go @@ -638,9 +638,7 @@ func flattenNestedComputeRouterBgpPeer(d *schema.ResourceData, meta interface{}, v, ok = res["bgpPeers"] if !ok || v == nil { - // It's possible that there is only one of these resources and - // that res represents that resource. - v = res + return nil, nil } switch v.(type) { diff --git a/google-beta/resource_compute_router_nat.go b/google-beta/resource_compute_router_nat.go index e348658ec7..4f14e271d1 100644 --- a/google-beta/resource_compute_router_nat.go +++ b/google-beta/resource_compute_router_nat.go @@ -999,9 +999,7 @@ func flattenNestedComputeRouterNat(d *schema.ResourceData, meta interface{}, res v, ok = res["nats"] if !ok || v == nil { - // It's possible that there is only one of these resources and - // that res represents that resource. - v = res + return nil, nil } switch v.(type) { diff --git a/google-beta/resource_firebase_project_location.go b/google-beta/resource_firebase_project_location.go index 92be7a2dd8..02c8d6702d 100644 --- a/google-beta/resource_firebase_project_location.go +++ b/google-beta/resource_firebase_project_location.go @@ -186,9 +186,7 @@ func flattenNestedFirebaseProjectLocation(d *schema.ResourceData, meta interface v, ok = res["resources"] if !ok || v == nil { - // It's possible that there is only one of these resources and - // that res represents that resource. - v = res + return nil, nil } switch v.(type) { diff --git a/google-beta/resource_resource_manager_lien.go b/google-beta/resource_resource_manager_lien.go index 7b128f1dee..17fee8448e 100644 --- a/google-beta/resource_resource_manager_lien.go +++ b/google-beta/resource_resource_manager_lien.go @@ -317,9 +317,7 @@ func flattenNestedResourceManagerLien(d *schema.ResourceData, meta interface{}, v, ok = res["liens"] if !ok || v == nil { - // It's possible that there is only one of these resources and - // that res represents that resource. - v = res + return nil, nil } switch v.(type) { diff --git a/google-beta/resource_service_usage_consumer_quota_override.go b/google-beta/resource_service_usage_consumer_quota_override.go index 2ea5eda0da..74243fdb8b 100644 --- a/google-beta/resource_service_usage_consumer_quota_override.go +++ b/google-beta/resource_service_usage_consumer_quota_override.go @@ -344,9 +344,7 @@ func flattenNestedServiceUsageConsumerQuotaOverride(d *schema.ResourceData, meta v, ok = res["overrides"] if !ok || v == nil { - // It's possible that there is only one of these resources and - // that res represents that resource. - v = res + return nil, nil } switch v.(type) {