Skip to content

Commit

Permalink
azurerm_storage_account - Check `blob_properties.0.versioning_enabl…
Browse files Browse the repository at this point in the history
…ed` and `is_hns_enabled` (hashicorp#19418)

Fix hashicorp#19414

Relates-to: hashicorp#14736
  • Loading branch information
magodo authored and leesutcliffe committed Nov 24, 2022
1 parent 2e78067 commit 965e387
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/services/storage/storage_account_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,11 @@ func resourceStorageAccountCreate(d *pluginsdk.ResourceData, meta interface{}) e
blobProperties.ContainerDeleteRetentionPolicy = expandBlobPropertiesDeleteRetentionPolicy(v.([]interface{}))
}

// See: https://learn.microsoft.com/en-us/azure/storage/blobs/versioning-overview#:~:text=Storage%20accounts%20with%20a%20hierarchical%20namespace%20enabled%20for%20use%20with%20Azure%20Data%20Lake%20Storage%20Gen2%20are%20not%20currently%20supported.
if blobProperties.IsVersioningEnabled != nil && *blobProperties.IsVersioningEnabled && isHnsEnabled {
return fmt.Errorf("`versioning_enabled` can't be true when `is_hns_enabled` is true")
}

if _, err = blobClient.SetServiceProperties(ctx, id.ResourceGroup, id.Name, *blobProperties); err != nil {
return fmt.Errorf("updating Azure Storage Account `blob_properties` %q: %+v", id.Name, err)
}
Expand Down Expand Up @@ -1769,6 +1774,10 @@ func resourceStorageAccountUpdate(d *pluginsdk.ResourceData, meta interface{}) e
blobProperties.ContainerDeleteRetentionPolicy = expandBlobPropertiesDeleteRetentionPolicy(d.Get("blob_properties.0.container_delete_retention_policy").([]interface{}))
}

if blobProperties.IsVersioningEnabled != nil && *blobProperties.IsVersioningEnabled && d.Get("is_hns_enabled").(bool) {
return fmt.Errorf("`versioning_enabled` can't be true when `is_hns_enabled` is true")
}

if _, err = blobClient.SetServiceProperties(ctx, id.ResourceGroup, id.Name, *blobProperties); err != nil {
return fmt.Errorf("updating Azure Storage Account `blob_properties` %q: %+v", id.Name, err)
}
Expand Down

0 comments on commit 965e387

Please sign in to comment.