Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_storage_account - fixes #302 #421

Merged
merged 2 commits into from
Oct 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions azurerm/resource_arm_storage_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this check be needed in Update too as account_replication_type is not ForceNew?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, most of the Azure resources are CreateOrUpdate - so I'd assumed this was the same - I'll update it now..

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"
Expand Down Expand Up @@ -321,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),
}
Expand All @@ -351,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)
Expand Down