diff --git a/.changelog/12600.txt b/.changelog/12600.txt new file mode 100644 index 00000000000..382f2d6754a --- /dev/null +++ b/.changelog/12600.txt @@ -0,0 +1,3 @@ +```release-note:bug +networkservices: fix `google_network_services_gateway` resource so that it correctly waits for the router to be deleted on `terraform destroy` +``` \ No newline at end of file diff --git a/google/services/networkservices/resource_network_services_gateway.go b/google/services/networkservices/resource_network_services_gateway.go index 3d25e8aaa7a..4bcfed5af26 100644 --- a/google/services/networkservices/resource_network_services_gateway.go +++ b/google/services/networkservices/resource_network_services_gateway.go @@ -31,6 +31,8 @@ import ( "github.com/hashicorp/terraform-provider-google/google/tpgresource" transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" "github.com/hashicorp/terraform-provider-google/google/verify" + + tpgcompute "github.com/hashicorp/terraform-provider-google/google/services/compute" ) // Checks if there is another gateway under the same location. @@ -127,7 +129,7 @@ func deleteSWGAutoGenRouter(d *schema.ResourceData, config *transport_tpg.Config return err } - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ + res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "DELETE", Project: billingProject, @@ -145,6 +147,10 @@ func deleteSWGAutoGenRouter(d *schema.ResourceData, config *transport_tpg.Config return err } + err = tpgcompute.ComputeOperationWaitTime( + config, res, billingProject, "Deleting autogen router", userAgent, + d.Timeout(schema.TimeoutDelete)) + return nil }