From 0e4df929f2da7306139f624df4cffa961b1b071b Mon Sep 17 00:00:00 2001 From: Alex Stephen Date: Mon, 8 Jul 2019 19:28:11 +0000 Subject: [PATCH] Spanner Fixes Signed-off-by: Modular Magician --- google/resource_spanner_database.go | 14 ++++++++++++++ google/resource_spanner_instance.go | 26 -------------------------- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/google/resource_spanner_database.go b/google/resource_spanner_database.go index 05f36be47a1..d0a2ecc1345 100644 --- a/google/resource_spanner_database.go +++ b/google/resource_spanner_database.go @@ -119,6 +119,20 @@ func resourceSpannerDatabaseCreate(d *schema.ResourceData, meta interface{}) err } d.SetId(id) + project, err := getProject(d, config) + if err != nil { + return err + } + waitErr := spannerOperationWaitTime( + config, res, project, "Creating Database", + int(d.Timeout(schema.TimeoutCreate).Minutes())) + + if waitErr != nil { + // The resource didn't actually create + d.SetId("") + return fmt.Errorf("Error waiting to create Database: %s", waitErr) + } + log.Printf("[DEBUG] Finished creating Database %q: %#v", d.Id(), res) return resourceSpannerDatabaseRead(d, meta) diff --git a/google/resource_spanner_instance.go b/google/resource_spanner_instance.go index 5895429c4e6..42808eaacfe 100644 --- a/google/resource_spanner_instance.go +++ b/google/resource_spanner_instance.go @@ -261,19 +261,6 @@ func resourceSpannerInstanceUpdate(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("Error updating Instance %q: %s", d.Id(), err) } - project, err := getProject(d, config) - if err != nil { - return err - } - - err = spannerOperationWaitTime( - config, res, project, "Updating Instance", - int(d.Timeout(schema.TimeoutUpdate).Minutes())) - - if err != nil { - return err - } - return resourceSpannerInstanceRead(d, meta) } @@ -292,19 +279,6 @@ func resourceSpannerInstanceDelete(d *schema.ResourceData, meta interface{}) err return handleNotFoundError(err, d, "Instance") } - project, err := getProject(d, config) - if err != nil { - return err - } - - err = spannerOperationWaitTime( - config, res, project, "Deleting Instance", - int(d.Timeout(schema.TimeoutDelete).Minutes())) - - if err != nil { - return err - } - log.Printf("[DEBUG] Finished deleting Instance %q: %#v", d.Id(), res) return nil }