From a3ed6de99a0e2692c39a3dc7b302b43bc9433061 Mon Sep 17 00:00:00 2001 From: The Magician Date: Mon, 6 Jan 2025 08:42:19 -0800 Subject: [PATCH] Secure Web Proxy deleteSWGAutoGenRouter wait the operation to finish (#12600) (#20817) [upstream:4e86784f2ed69f1afa7ee3b0ff6e4846f246e4e6] Signed-off-by: Modular Magician --- .changelog/12600.txt | 3 +++ .../networkservices/resource_network_services_gateway.go | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changelog/12600.txt 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 }