From 25e1681e5d8cebbc7c3debab5c6a5ab0afbca88d Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Thu, 12 Oct 2017 16:02:27 +0100 Subject: [PATCH 1/2] Returning a user friendly error when trying to provision a Blob Storage Account with `ZRS` redundancy Fixes #302 --- azurerm/resource_arm_storage_account.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/azurerm/resource_arm_storage_account.go b/azurerm/resource_arm_storage_account.go index 0f0e9c982933..cad87660194b 100644 --- a/azurerm/resource_arm_storage_account.go +++ b/azurerm/resource_arm_storage_account.go @@ -253,6 +253,10 @@ func resourceArmStorageAccountCreate(d *schema.ResourceData, meta interface{}) e // AccessTier is only valid for BlobStorage accounts if accountKind == string(storage.BlobStorage) { + if string(parameters.Sku.Name) == string(storage.StandardZRS) { + return fmt.Errorf("A `account_replication_type` of `ZRS` isn't supported for Blob Storage accounts.") + } + accessTier, ok := d.GetOk("access_tier") if !ok { // default to "Hot" From 1de36831495566e0556e1a2299a90e7ff5331352 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Thu, 12 Oct 2017 18:02:30 +0100 Subject: [PATCH 2/2] supporting update too --- azurerm/resource_arm_storage_account.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/azurerm/resource_arm_storage_account.go b/azurerm/resource_arm_storage_account.go index cad87660194b..42bc70218f0c 100644 --- a/azurerm/resource_arm_storage_account.go +++ b/azurerm/resource_arm_storage_account.go @@ -325,13 +325,20 @@ func resourceArmStorageAccountUpdate(d *schema.ResourceData, meta interface{}) e storageAccountName := id.Path["storageAccounts"] resourceGroupName := id.ResourceGroup + accountTier := d.Get("account_tier").(string) + replicationType := d.Get("account_replication_type").(string) + storageType := fmt.Sprintf("%s_%s", accountTier, replicationType) + accountKind := d.Get("account_kind").(string) + + if accountKind == string(storage.BlobStorage) { + if storageType == string(storage.StandardZRS) { + return fmt.Errorf("A `account_replication_type` of `ZRS` isn't supported for Blob Storage accounts.") + } + } + d.Partial(true) if d.HasChange("account_replication_type") { - accountTier := d.Get("account_tier").(string) - replicationType := d.Get("account_replication_type").(string) - storageType := fmt.Sprintf("%s_%s", accountTier, replicationType) - sku := storage.Sku{ Name: storage.SkuName(storageType), } @@ -355,6 +362,7 @@ func resourceArmStorageAccountUpdate(d *schema.ResourceData, meta interface{}) e AccessTier: storage.AccessTier(accessTier), }, } + _, err := client.Update(resourceGroupName, storageAccountName, opts) if err != nil { return fmt.Errorf("Error updating Azure Storage Account access_tier %q: %+v", storageAccountName, err)