From ecad167e317f87a7d170fdcbcaa66b740c35b89f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 16 Aug 2016 09:42:05 -0700 Subject: [PATCH] providers/azurerm: address PR feedback --- .../azurerm/resource_arm_storage_account.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/builtin/providers/azurerm/resource_arm_storage_account.go b/builtin/providers/azurerm/resource_arm_storage_account.go index cbeb1a5288..183a7b0bb5 100644 --- a/builtin/providers/azurerm/resource_arm_storage_account.go +++ b/builtin/providers/azurerm/resource_arm_storage_account.go @@ -139,8 +139,7 @@ func resourceArmStorageAccountCreate(d *schema.ResourceData, meta interface{}) e return err }) - // Check the result of the wrapped function. I put this into a select - // since we will likely also want to introduce a time-based timeout. + // Check the result of the wrapped function. var createErr error select { case <-time.After(1 * time.Hour): @@ -154,12 +153,9 @@ func resourceArmStorageAccountCreate(d *schema.ResourceData, meta interface{}) e // The only way to get the ID back apparently is to read the resource again read, err := storageClient.GetProperties(resourceGroupName, storageAccountName) - if err != nil { - return err - } // Set the ID right away if we have one - if read.ID != nil { + if read != nil && read.ID != nil { log.Printf("[INFO] storage account %q ID: %q", storageAccountName, *read.ID) d.SetId(*read.ID) } @@ -172,6 +168,11 @@ func resourceArmStorageAccountCreate(d *schema.ResourceData, meta interface{}) e storageAccountName, createErr) } + // Check the read error now that we know it would exist without a create err + if err != nil { + return err + } + // If we got no ID then the resource group doesn't yet exist if read.ID == nil { return fmt.Errorf("Cannot read Storage Account %s (resource group %s) ID",