From 43b848abef221ede30fa823b56e1a1db11d89ce3 Mon Sep 17 00:00:00 2001 From: kt Date: Wed, 31 Jul 2019 17:24:59 -0400 Subject: [PATCH] storage: always nil check resource group before deref (#3986) --- azurerm/resource_arm_storage_container.go | 17 +++++++++------- .../resource_arm_storage_container_test.go | 12 ++++++++--- azurerm/resource_arm_storage_queue.go | 10 ++++------ azurerm/resource_arm_storage_share.go | 17 +++++++++------- .../resource_arm_storage_share_directory.go | 20 +++++++++++++------ ...source_arm_storage_share_directory_test.go | 7 +++++-- azurerm/resource_arm_storage_share_test.go | 12 ++++++++--- azurerm/resource_arm_storage_table.go | 17 +++++++++------- azurerm/resource_arm_storage_table_entity.go | 20 +++++++++++++------ .../resource_arm_storage_table_entity_test.go | 7 +++++-- azurerm/resource_arm_storage_table_test.go | 10 +++++----- 11 files changed, 95 insertions(+), 54 deletions(-) diff --git a/azurerm/resource_arm_storage_container.go b/azurerm/resource_arm_storage_container.go index ab72eb2bbb5d..1ff39359b55b 100644 --- a/azurerm/resource_arm_storage_container.go +++ b/azurerm/resource_arm_storage_container.go @@ -89,7 +89,10 @@ func resourceArmStorageContainerCreate(d *schema.ResourceData, meta interface{}) resourceGroup, err := storageClient.FindResourceGroup(ctx, accountName) if err != nil { - return fmt.Errorf("Error locating Resource Group: %s", err) + return fmt.Errorf("Error locating Resource Group for Storage Container %q (Account %s): %s", containerName, accountName, err) + } + if resourceGroup == nil { + return fmt.Errorf("Unable to locate Resource Group for Storage Container %q (Account %s)", containerName, accountName) } client, err := storageClient.ContainersClient(ctx, *resourceGroup, accountName) @@ -135,10 +138,10 @@ func resourceArmStorageContainerUpdate(d *schema.ResourceData, meta interface{}) resourceGroup, err := storageClient.FindResourceGroup(ctx, id.AccountName) if err != nil { - return fmt.Errorf("Error locating Resource Group for Storage Account %q: %s", id.AccountName, err) + return fmt.Errorf("Error locating Resource Group for Storage Container %q (Account %s): %s", id.ContainerName, id.AccountName, err) } if resourceGroup == nil { - log.Printf("[DEBUG] Unable to locate Resource Group for Storage Account %q - assuming removed & removing from state", id.AccountName) + log.Printf("[DEBUG] Unable to locate Resource Group for Storage Container %q (Account %s) - assuming removed & removing from state", id.ContainerName, id.AccountName) d.SetId("") return nil } @@ -184,10 +187,10 @@ func resourceArmStorageContainerRead(d *schema.ResourceData, meta interface{}) e resourceGroup, err := storageClient.FindResourceGroup(ctx, id.AccountName) if err != nil { - return fmt.Errorf("Error locating Resource Group for Storage Account %q: %s", id.AccountName, err) + return fmt.Errorf("Error locating Resource Group for Storage Container %q (Account %s): %s", id.ContainerName, id.AccountName, err) } if resourceGroup == nil { - log.Printf("[DEBUG] Unable to locate Resource Group for Storage Account %q - assuming removed & removing from state", id.AccountName) + log.Printf("[DEBUG] Unable to locate Resource Group for Storage Container %q (Account %s) - assuming removed & removing from state", id.ContainerName, id.AccountName) d.SetId("") return nil } @@ -239,10 +242,10 @@ func resourceArmStorageContainerDelete(d *schema.ResourceData, meta interface{}) resourceGroup, err := storageClient.FindResourceGroup(ctx, id.AccountName) if err != nil { - return fmt.Errorf("Error locating Resource Group for Storage Account %q: %s", id.AccountName, err) + return fmt.Errorf("Error locating Resource Group for Storage Container %q (Account %s): %s", id.ContainerName, id.AccountName, err) } if resourceGroup == nil { - log.Printf("[DEBUG] Unable to locate Resource Group for Storage Account %q - assuming removed & removing from state", id.AccountName) + log.Printf("[DEBUG] Unable to locate Resource Group for Storage Container %q (Account %s) - assuming removed & removing from state", id.ContainerName, id.AccountName) d.SetId("") return nil } diff --git a/azurerm/resource_arm_storage_container_test.go b/azurerm/resource_arm_storage_container_test.go index 02d6d007be7c..9fa5062777d4 100644 --- a/azurerm/resource_arm_storage_container_test.go +++ b/azurerm/resource_arm_storage_container_test.go @@ -249,7 +249,10 @@ func testCheckAzureRMStorageContainerExists(resourceName string) resource.TestCh resourceGroup, err := storageClient.FindResourceGroup(ctx, accountName) if err != nil { - return fmt.Errorf("Error finding Resource Group: %s", err) + return fmt.Errorf("Error locating Resource Group for Storage Container %q (Account %s): %s", containerName, accountName, err) + } + if resourceGroup == nil { + return fmt.Errorf("Unable to locate Resource Group for Storage Container %q (Account %s) - assuming removed & removing from state", containerName, accountName) } client, err := storageClient.ContainersClient(ctx, *resourceGroup, accountName) @@ -285,7 +288,10 @@ func testAccARMStorageContainerDisappears(resourceName string) resource.TestChec resourceGroup, err := storageClient.FindResourceGroup(ctx, accountName) if err != nil { - return fmt.Errorf("Error finding Resource Group: %s", err) + return fmt.Errorf("Error locating Resource Group for Storage Container %q (Account %s): %s", containerName, accountName, err) + } + if resourceGroup == nil { + return fmt.Errorf("Unable to locate Resource Group for Storage Container %q (Account %s) - assuming removed & removing from state", containerName, accountName) } client, err := storageClient.ContainersClient(ctx, *resourceGroup, accountName) @@ -315,7 +321,7 @@ func testCheckAzureRMStorageContainerDestroy(s *terraform.State) error { resourceGroup, err := storageClient.FindResourceGroup(ctx, accountName) if err != nil { - return fmt.Errorf("Error finding Resource Group: %s", err) + return fmt.Errorf("Error locating Resource Group for Storage Container %q (Account %s): %s", containerName, accountName, err) } if resourceGroup == nil { diff --git a/azurerm/resource_arm_storage_queue.go b/azurerm/resource_arm_storage_queue.go index d60403ec6c3f..ba3b46082e7d 100644 --- a/azurerm/resource_arm_storage_queue.go +++ b/azurerm/resource_arm_storage_queue.go @@ -139,11 +139,10 @@ func resourceArmStorageQueueRead(d *schema.ResourceData, meta interface{}) error resourceGroup, err := storageClient.FindResourceGroup(ctx, id.AccountName) if err != nil { - return fmt.Errorf("Error locating Resource Group: %s", err) + return fmt.Errorf("Error locating Resource Group for Queue Container %q (Account %s): %s", id.QueueName, id.AccountName, err) } - if resourceGroup == nil { - log.Printf("[WARN] Unable to determine Resource Group for Storage Account %q (assuming removed) - removing from state", id.AccountName) + log.Printf("[WARN] Unable to determine Resource Group for Storage Queue %q (Account %s) - assuming removed & removing from state", id.QueueName, id.AccountName) d.SetId("") return nil } @@ -181,11 +180,10 @@ func resourceArmStorageQueueDelete(d *schema.ResourceData, meta interface{}) err resourceGroup, err := storageClient.FindResourceGroup(ctx, id.AccountName) if err != nil { - return fmt.Errorf("Error locating Resource Group: %s", err) + return fmt.Errorf("Error locating Resource Group for Storage Queue %q (Account %s): %s", id.QueueName, id.AccountName, err) } - if resourceGroup == nil { - log.Printf("[WARN] Unable to determine Resource Group for Storage Account %q (assuming removed) - removing from state", id.AccountName) + log.Printf("[WARN] Unable to determine Resource Group for Storage Queue %q (Account %s) - assuming removed & removing from state", id.QueueName, id.AccountName) d.SetId("") return nil } diff --git a/azurerm/resource_arm_storage_share.go b/azurerm/resource_arm_storage_share.go index 6171e79d9ae9..d0f2834ac733 100644 --- a/azurerm/resource_arm_storage_share.go +++ b/azurerm/resource_arm_storage_share.go @@ -124,7 +124,10 @@ func resourceArmStorageShareCreate(d *schema.ResourceData, meta interface{}) err resourceGroup, err := storageClient.FindResourceGroup(ctx, accountName) if err != nil { - return fmt.Errorf("Error locating Resource Group: %s", err) + return fmt.Errorf("Error locating Resource Group for Storage Share %q (Account %s): %s", shareName, accountName, err) + } + if resourceGroup == nil { + return fmt.Errorf("Unable to locate Resource Group for Storage Share %q (Account %s) - assuming removed & removing from state", shareName, accountName) } client, err := storageClient.FileSharesClient(ctx, *resourceGroup, accountName) @@ -175,10 +178,10 @@ func resourceArmStorageShareRead(d *schema.ResourceData, meta interface{}) error resourceGroup, err := storageClient.FindResourceGroup(ctx, id.AccountName) if err != nil { - return fmt.Errorf("Error locating Resource Group for Storage Account %q: %s", id.AccountName, err) + return fmt.Errorf("Error locating Resource Group for Storage Share %q (Account %s): %s", id.ShareName, id.AccountName, err) } if resourceGroup == nil { - log.Printf("[DEBUG] Unable to locate Resource Group for Storage Account %q - assuming removed & removing from state", id.AccountName) + log.Printf("[WARN] Unable to determine Resource Group for Storage Share %q (Account %s) - assuming removed & removing from state", id.ShareName, id.AccountName) d.SetId("") return nil } @@ -234,10 +237,10 @@ func resourceArmStorageShareUpdate(d *schema.ResourceData, meta interface{}) err resourceGroup, err := storageClient.FindResourceGroup(ctx, id.AccountName) if err != nil { - return fmt.Errorf("Error locating Resource Group for Storage Account %q: %s", id.AccountName, err) + return fmt.Errorf("Error locating Resource Group for Storage Share %q (Account %s): %s", id.ShareName, id.AccountName, err) } if resourceGroup == nil { - log.Printf("[DEBUG] Unable to locate Resource Group for Storage Account %q - assuming removed & removing from state", id.AccountName) + log.Printf("[WARN] Unable to determine Resource Group for Storage Share %q (Account %s) - assuming removed & removing from state", id.ShareName, id.AccountName) d.SetId("") return nil } @@ -297,10 +300,10 @@ func resourceArmStorageShareDelete(d *schema.ResourceData, meta interface{}) err resourceGroup, err := storageClient.FindResourceGroup(ctx, id.AccountName) if err != nil { - return fmt.Errorf("Error locating Resource Group for Storage Account %q: %s", id.AccountName, err) + return fmt.Errorf("Error locating Resource Group for Storage Share %q (Account %s): %s", id.ShareName, id.AccountName, err) } if resourceGroup == nil { - log.Printf("[DEBUG] Unable to locate Resource Group for Storage Account %q - assuming removed & removing from state", id.AccountName) + log.Printf("[WARN] Unable to determine Resource Group for Storage Share %q (Account %s) - assuming removed & removing from state", id.ShareName, id.AccountName) d.SetId("") return nil } diff --git a/azurerm/resource_arm_storage_share_directory.go b/azurerm/resource_arm_storage_share_directory.go index 974a7898d60a..1d28bb8ec16e 100644 --- a/azurerm/resource_arm_storage_share_directory.go +++ b/azurerm/resource_arm_storage_share_directory.go @@ -60,7 +60,10 @@ func resourceArmStorageShareDirectoryCreate(d *schema.ResourceData, meta interfa resourceGroup, err := storageClient.FindResourceGroup(ctx, accountName) if err != nil { - return fmt.Errorf("Error locating Resource Group: %s", err) + return fmt.Errorf("Error locating Resource Group for Storage Share Directory %q (Share %s, Account %s): %s", directoryName, shareName, accountName, err) + } + if resourceGroup == nil { + return fmt.Errorf("Unable to locate Resource Group for Storage Share Directory %q (Share %s, Account %s) ", directoryName, shareName, accountName) } client, err := storageClient.FileShareDirectoriesClient(ctx, *resourceGroup, accountName) @@ -106,7 +109,12 @@ func resourceArmStorageShareDirectoryUpdate(d *schema.ResourceData, meta interfa resourceGroup, err := storageClient.FindResourceGroup(ctx, id.AccountName) if err != nil { - return fmt.Errorf("Error locating Resource Group: %s", err) + return fmt.Errorf("Error locating Resource Group for Storage Share Directory %q (Share %s, Account %s): %s", id.DirectoryName, id.ShareName, id.AccountName, err) + } + if resourceGroup == nil { + log.Printf("[WARN] Unable to determine Resource Group for Storage Share Directory %q (Share %s, Account %s) - assuming removed & removing from state", id.DirectoryName, id.ShareName, id.AccountName) + d.SetId("") + return nil } client, err := storageClient.FileShareDirectoriesClient(ctx, *resourceGroup, id.AccountName) @@ -132,10 +140,10 @@ func resourceArmStorageShareDirectoryRead(d *schema.ResourceData, meta interface resourceGroup, err := storageClient.FindResourceGroup(ctx, id.AccountName) if err != nil { - return fmt.Errorf("Error locating Resource Group for Storage Account %q: %s", id.AccountName, err) + return fmt.Errorf("Error locating Resource Group for Storage Share Directory %q (Share %s, Account %s): %s", id.DirectoryName, id.ShareName, id.AccountName, err) } if resourceGroup == nil { - log.Printf("[DEBUG] Unable to locate Resource Group for Storage Account %q - assuming removed & removing from state", id.AccountName) + log.Printf("[WARN] Unable to determine Resource Group for Storage Share Directory %q (Share %s, Account %s) - assuming removed & removing from state", id.DirectoryName, id.ShareName, id.AccountName) d.SetId("") return nil } @@ -172,10 +180,10 @@ func resourceArmStorageShareDirectoryDelete(d *schema.ResourceData, meta interfa resourceGroup, err := storageClient.FindResourceGroup(ctx, id.AccountName) if err != nil { - return fmt.Errorf("Error locating Resource Group for Storage Account %q: %s", id.AccountName, err) + return fmt.Errorf("Error locating Resource Group for Storage Share Directory %q (Share %s, Account %s): %s", id.DirectoryName, id.ShareName, id.AccountName, err) } if resourceGroup == nil { - log.Printf("[DEBUG] Unable to locate Resource Group for Storage Account %q - assuming removed already", id.AccountName) + log.Printf("[WARN] Unable to determine Resource Group for Storage Share Directory %q (Share %s, Account %s) - assuming removed already", id.DirectoryName, id.ShareName, id.AccountName) d.SetId("") return nil } diff --git a/azurerm/resource_arm_storage_share_directory_test.go b/azurerm/resource_arm_storage_share_directory_test.go index 1173bf03e042..4d9b78b04645 100644 --- a/azurerm/resource_arm_storage_share_directory_test.go +++ b/azurerm/resource_arm_storage_share_directory_test.go @@ -168,7 +168,10 @@ func testCheckAzureRMStorageShareDirectoryExists(resourceName string) resource.T resourceGroup, err := storageClient.FindResourceGroup(ctx, accountName) if err != nil { - return fmt.Errorf("Error finding Resource Group: %s", err) + return fmt.Errorf("Error locating Resource Group for Storage Share Directory %q (Share %s, Account %s): %s", name, shareName, accountName, err) + } + if resourceGroup == nil { + return fmt.Errorf("Unable to locate Resource Group for Storage Share Directory %q (Share %s, Account %s) ", name, shareName, accountName) } client, err := storageClient.FileShareDirectoriesClient(ctx, *resourceGroup, accountName) @@ -204,7 +207,7 @@ func testCheckAzureRMStorageShareDirectoryDestroy(s *terraform.State) error { resourceGroup, err := storageClient.FindResourceGroup(ctx, accountName) if err != nil { - return fmt.Errorf("Error finding Resource Group: %s", err) + return fmt.Errorf("Error locating Resource Group for Storage Share Directory %q (Share %s, Account %s): %s", name, shareName, accountName, err) } // not found, the account's gone diff --git a/azurerm/resource_arm_storage_share_test.go b/azurerm/resource_arm_storage_share_test.go index fc77b9290aff..8c30648da4d9 100644 --- a/azurerm/resource_arm_storage_share_test.go +++ b/azurerm/resource_arm_storage_share_test.go @@ -208,7 +208,10 @@ func testCheckAzureRMStorageShareExists(resourceName string) resource.TestCheckF resourceGroup, err := storageClient.FindResourceGroup(ctx, accountName) if err != nil { - return fmt.Errorf("Error finding Resource Group: %s", err) + return fmt.Errorf("Error locating Resource Group for Storage Share %q (Account %s): %s", shareName, accountName, err) + } + if resourceGroup == nil { + return fmt.Errorf("Unable to locate Resource Group for Storage Share %q (Account %s) - assuming removed & removing from state", shareName, accountName) } client, err := storageClient.FileSharesClient(ctx, *resourceGroup, accountName) @@ -239,7 +242,10 @@ func testCheckAzureRMStorageShareDisappears(resourceName string) resource.TestCh resourceGroup, err := storageClient.FindResourceGroup(ctx, accountName) if err != nil { - return fmt.Errorf("Error finding Resource Group: %s", err) + return fmt.Errorf("Error locating Resource Group for Storage Share %q (Account %s): %s", shareName, accountName, err) + } + if resourceGroup == nil { + return fmt.Errorf("Unable to locate Resource Group for Storage Share %q (Account %s) - assuming removed & removing from state", shareName, accountName) } client, err := storageClient.FileSharesClient(ctx, *resourceGroup, accountName) @@ -269,7 +275,7 @@ func testCheckAzureRMStorageShareDestroy(s *terraform.State) error { resourceGroup, err := storageClient.FindResourceGroup(ctx, accountName) if err != nil { - return fmt.Errorf("Error finding Resource Group: %s", err) + return fmt.Errorf("Error locating Resource Group for Storage Share %q (Account %s): %s", shareName, accountName, err) } if resourceGroup == nil { return nil diff --git a/azurerm/resource_arm_storage_table.go b/azurerm/resource_arm_storage_table.go index a1efa05e1b26..626519fe1eed 100644 --- a/azurerm/resource_arm_storage_table.go +++ b/azurerm/resource_arm_storage_table.go @@ -107,7 +107,10 @@ func resourceArmStorageTableCreate(d *schema.ResourceData, meta interface{}) err resourceGroup, err := storageClient.FindResourceGroup(ctx, accountName) if err != nil { - return fmt.Errorf("Error locating Resource Group: %s", err) + return fmt.Errorf("Error locating Resource Group for Storage Table %q (Account %s): %s", tableName, accountName, err) + } + if resourceGroup == nil { + return fmt.Errorf("Unable to locate Resource Group for Storage Share %q (Account %s) - assuming removed & removing from state", tableName, accountName) } client, err := storageClient.TablesClient(ctx, *resourceGroup, accountName) @@ -153,11 +156,11 @@ func resourceArmStorageTableRead(d *schema.ResourceData, meta interface{}) error resourceGroup, err := storageClient.FindResourceGroup(ctx, id.AccountName) if err != nil { - return fmt.Errorf("Error locating Resource Group: %s", err) + return fmt.Errorf("Error locating Resource Group for Storage Table %q (Account %s): %s", id.TableName, id.AccountName, err) } if resourceGroup == nil { - log.Printf("Unable to determine Resource Group for Storage Account %q (assuming removed)", id.AccountName) + log.Printf("Unable to determine Resource Group for Storage Storage Table %q (Account %s) - assuming removed & removing from state", id.TableName, id.AccountName) d.SetId("") return nil } @@ -205,11 +208,11 @@ func resourceArmStorageTableDelete(d *schema.ResourceData, meta interface{}) err resourceGroup, err := storageClient.FindResourceGroup(ctx, id.AccountName) if err != nil { - return fmt.Errorf("Error locating Resource Group: %s", err) + return fmt.Errorf("Error locating Resource Group for Storage Table %q (Account %s): %s", id.TableName, id.AccountName, err) } if resourceGroup == nil { - log.Printf("Unable to determine Resource Group for Storage Account %q (assuming removed)", id.AccountName) + log.Printf("Unable to determine Resource Group for Storage Storage Table %q (Account %s) - assuming removed & removing from state", id.TableName, id.AccountName) return nil } @@ -237,11 +240,11 @@ func resourceArmStorageTableUpdate(d *schema.ResourceData, meta interface{}) err resourceGroup, err := storageClient.FindResourceGroup(ctx, id.AccountName) if err != nil { - return fmt.Errorf("Error locating Resource Group: %s", err) + return fmt.Errorf("Error locating Resource Group for Storage Table %q (Account %s): %s", id.TableName, id.AccountName, err) } if resourceGroup == nil { - log.Printf("Unable to determine Resource Group for Storage Account %q (assuming removed)", id.AccountName) + log.Printf("Unable to determine Resource Group for Storage Storage Table %q (Account %s) - assuming removed & removing from state", id.TableName, id.AccountName) d.SetId("") return nil } diff --git a/azurerm/resource_arm_storage_table_entity.go b/azurerm/resource_arm_storage_table_entity.go index 3a172c2ff565..97fbc4ffdf02 100644 --- a/azurerm/resource_arm_storage_table_entity.go +++ b/azurerm/resource_arm_storage_table_entity.go @@ -69,7 +69,16 @@ func resourceArmStorageTableEntityCreateUpdate(d *schema.ResourceData, meta inte resourceGroup, err := storageClient.FindResourceGroup(ctx, accountName) if err != nil { - return fmt.Errorf("Error locating Resource Group: %s", err) + return fmt.Errorf("Error locating Resource Group for Storage Stable %q (Account %s): %s", tableName, accountName, err) + } + if resourceGroup == nil { + if d.IsNewResource() { + return fmt.Errorf("Unable to locate Resource Group for Storage Table %q (Account %s)", tableName, accountName) + } else { + log.Printf("[DEBUG] Unable to locate Resource Group for Storage Table %q (Account %s) - assuming removed & removing from state", tableName, accountName) + d.SetId("") + return nil + } } client, err := storageClient.TableEntityClient(ctx, *resourceGroup, accountName) @@ -123,10 +132,10 @@ func resourceArmStorageTableEntityRead(d *schema.ResourceData, meta interface{}) resourceGroup, err := storageClient.FindResourceGroup(ctx, id.AccountName) if err != nil { - return fmt.Errorf("Error locating Resource Group for Storage Account %q: %s", id.AccountName, err) + return fmt.Errorf("Error locating Resource Group for Storage Table %q (Account %s): %s", id.TableName, id.AccountName, err) } if resourceGroup == nil { - log.Printf("[DEBUG] Unable to locate Resource Group for Storage Account %q - assuming removed & removing from state", id.AccountName) + log.Printf("[WARN] Unable to determine Resource Group for Storage Table %q (Account %s) - assuming removed & removing from state", id.TableName, id.AccountName) d.SetId("") return nil } @@ -169,11 +178,10 @@ func resourceArmStorageTableEntityDelete(d *schema.ResourceData, meta interface{ resourceGroup, err := storageClient.FindResourceGroup(ctx, id.AccountName) if err != nil { - return fmt.Errorf("Error locating Resource Group for Storage Account %q: %s", id.AccountName, err) + return fmt.Errorf("Error locating Resource Group for Storage Table %q (Account %s): %s", id.TableName, id.AccountName, err) } if resourceGroup == nil { - log.Printf("[DEBUG] Unable to locate Resource Group for Storage Account %q - assuming removed already", id.AccountName) - d.SetId("") + log.Printf("[WARN] Unable to determine Resource Group for Storage Table %q (Account %s) - assuming removed already", id.TableName, id.AccountName) return nil } diff --git a/azurerm/resource_arm_storage_table_entity_test.go b/azurerm/resource_arm_storage_table_entity_test.go index 36e10a76c47d..9ed93a688056 100644 --- a/azurerm/resource_arm_storage_table_entity_test.go +++ b/azurerm/resource_arm_storage_table_entity_test.go @@ -124,7 +124,10 @@ func testCheckAzureRMTableEntityExists(resourceName string) resource.TestCheckFu resourceGroup, err := storageClient.FindResourceGroup(ctx, accountName) if err != nil { - return fmt.Errorf("Error finding Resource Group: %s", err) + return fmt.Errorf("Error locating Resource Group for Storage Table Entity (Partition Key %q / Row Key %q) (Table %q / Account %q): %v", partitionKey, rowKey, tableName, accountName, err) + } + if resourceGroup == nil { + return fmt.Errorf("Unable to locate Resource Group for Storage Table Entity (Partition Key %q / Row Key %q) (Table %q / Account %q)", partitionKey, rowKey, tableName, accountName) } client, err := storageClient.TableEntityClient(ctx, *resourceGroup, accountName) @@ -166,7 +169,7 @@ func testCheckAzureRMTableEntityDestroy(s *terraform.State) error { resourceGroup, err := storageClient.FindResourceGroup(ctx, accountName) if err != nil { - return fmt.Errorf("Error finding Resource Group: %s", err) + return fmt.Errorf("Error locating Resource Group for Storage Table Entity (Partition Key %q / Row Key %q) (Table %q / Account %q / Resource Group %q): %v", partitionKey, rowKey, tableName, accountName, *resourceGroup, err) } // not found, the account's gone diff --git a/azurerm/resource_arm_storage_table_test.go b/azurerm/resource_arm_storage_table_test.go index 3c5421b5d99a..42aa58d1142b 100644 --- a/azurerm/resource_arm_storage_table_test.go +++ b/azurerm/resource_arm_storage_table_test.go @@ -152,10 +152,10 @@ func testCheckAzureRMStorageTableExists(resourceName string, t *storage.Table) r resourceGroup, err := storageClient.FindResourceGroup(ctx, accountName) if err != nil { - return fmt.Errorf("Error finding Resource Group: %s", err) + return fmt.Errorf("Error locating Resource Group for Storage Table %q (Account %s): %s", tableName, accountName, err) } if resourceGroup == nil { - return fmt.Errorf("Bad: no resource group found in state for storage table: %s", t.Name) + return fmt.Errorf("Unable to locate Resource Group for Storage Table %q (Account %s)", tableName, accountName) } client, err := storageClient.TablesClient(ctx, *resourceGroup, accountName) @@ -191,10 +191,10 @@ func testAccARMStorageTableDisappears(resourceName string, t *storage.Table) res resourceGroup, err := storageClient.FindResourceGroup(ctx, accountName) if err != nil { - return fmt.Errorf("Error finding Resource Group: %s", err) + return fmt.Errorf("Error locating Resource Group for Storage Table %q (Account %s): %s", tableName, accountName, err) } if resourceGroup == nil { - return fmt.Errorf("Bad: no resource group found in state for storage table: %s", t.Name) + return fmt.Errorf("Unable to locate Resource Group for Storage Table %q (Account %s)", tableName, accountName) } client, err := storageClient.TablesClient(ctx, *resourceGroup, accountName) @@ -233,7 +233,7 @@ func testCheckAzureRMStorageTableDestroy(s *terraform.State) error { resourceGroup, err := storageClient.FindResourceGroup(ctx, accountName) if err != nil { - return fmt.Errorf("Error finding Resource Group: %s", err) + return fmt.Errorf("Error locating Resource Group for Storage Table %q (Account %s): %s", tableName, accountName, err) } if resourceGroup == nil { return nil