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.
This commit is contained in:
Christoph Tavan 2017-05-02 23:01:05 +02:00
parent 7ecc515704
commit 08b9a11b42
No known key found for this signature in database
GPG Key ID: D9B600C63A37FD28
1 changed files with 7 additions and 3 deletions

View File

@ -200,11 +200,15 @@ func resourceComputeBackendServiceCreate(d *schema.ResourceData, meta interface{
log.Printf("[DEBUG] Waiting for new backend service, operation: %#v", op) log.Printf("[DEBUG] Waiting for new backend service, operation: %#v", op)
// Store the ID now
d.SetId(service.Name) d.SetId(service.Name)
err = computeOperationWaitGlobal(config, op, project, "Creating Backend Service") // Wait for the operation to complete
if err != nil { waitErr := computeOperationWaitGlobal(config, op, project, "Creating Backend Service")
return err if waitErr != nil {
// The resource didn't actually create
d.SetId("")
return waitErr
} }
return resourceComputeBackendServiceRead(d, meta) return resourceComputeBackendServiceRead(d, meta)