From 08b9a11b426928b09dbe150a509f106a05f073c7 Mon Sep 17 00:00:00 2001 From: Christoph Tavan Date: Tue, 2 May 2017 23:01:05 +0200 Subject: [PATCH] provider/google: Improve backend service error handling Unset id in case the backend service cannot be created. This basically updates these lines of code to match the more modern style which is being used e.g. for the google_compute_instance resource. --- .../google/resource_compute_backend_service.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/builtin/providers/google/resource_compute_backend_service.go b/builtin/providers/google/resource_compute_backend_service.go index cd4d9bd13..ebc3c5f1a 100644 --- a/builtin/providers/google/resource_compute_backend_service.go +++ b/builtin/providers/google/resource_compute_backend_service.go @@ -200,11 +200,15 @@ func resourceComputeBackendServiceCreate(d *schema.ResourceData, meta interface{ log.Printf("[DEBUG] Waiting for new backend service, operation: %#v", op) + // Store the ID now d.SetId(service.Name) - err = computeOperationWaitGlobal(config, op, project, "Creating Backend Service") - if err != nil { - return err + // Wait for the operation to complete + waitErr := computeOperationWaitGlobal(config, op, project, "Creating Backend Service") + if waitErr != nil { + // The resource didn't actually create + d.SetId("") + return waitErr } return resourceComputeBackendServiceRead(d, meta)