Skip to content

Commit

Permalink
azurerm_storage_account - Extend the support level of `(blob|queue|…
Browse files Browse the repository at this point in the history
…share)_properties` for `Storage` kind (#25427)

* Doc: Update document of `azurerm_storage_account` for the viable combinations for `(queue|share)_properties`

* Update website/docs/r/storage_account.html.markdown

Co-authored-by: Tom Harvey <tombuildsstuff@users.noreply.github.com>

* Update website/docs/r/storage_account.html.markdown

Co-authored-by: Tom Harvey <tombuildsstuff@users.noreply.github.com>

* Update website/docs/r/storage_account.html.markdown

Co-authored-by: Tom Harvey <tombuildsstuff@users.noreply.github.com>

* Extend the support level of blob|queue|share for `Storage` kind

* Update website/docs/r/storage_account.html.markdown

Co-authored-by: Tom Harvey <tombuildsstuff@users.noreply.github.com>

* Update website/docs/r/storage_account.html.markdown

Co-authored-by: Tom Harvey <tombuildsstuff@users.noreply.github.com>

---------

Co-authored-by: Tom Harvey <tombuildsstuff@users.noreply.github.com>
Co-authored-by: kt <kt@katbyte.me>
  • Loading branch information
3 people authored Apr 8, 2024
1 parent a25c648 commit 0777434
Show file tree
Hide file tree
Showing 3 changed files with 187 additions and 4 deletions.
6 changes: 3 additions & 3 deletions internal/services/storage/storage_account_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ func resolveStorageAccountServiceSupportLevel(kind storage.Kind, tier storage.Sk
supportBlob := kind != storage.KindFileStorage

// Queue is only supported for Storage and StorageV2, in Standard sku tier.
supportQueue := tier == storage.SkuTierStandard && kind == storage.KindStorageV2
supportQueue := tier == storage.SkuTierStandard && slices.Contains([]storage.Kind{storage.KindStorage, storage.KindStorageV2}, kind)

// File share is only supported for StorageV2 and FileStorage.
// See: https://docs.microsoft.com/en-us/azure/storage/files/storage-files-planning#management-concepts
// Per test, the StorageV2 with Premium sku tier also doesn't support file share.
supportShare := kind == storage.KindFileStorage || (kind == storage.KindStorageV2 && tier != storage.SkuTierPremium)
supportShare := kind == storage.KindFileStorage || (slices.Contains([]storage.Kind{storage.KindStorage, storage.KindStorageV2}, kind) && tier != storage.SkuTierPremium)

// Static Website is only supported for StorageV2 and BlockBlobStorage
// Static Website is only supported for StorageV2 (not for Storage(v1)) and BlockBlobStorage
supportStaticWebSite := kind == storage.KindStorageV2 || kind == storage.KindBlockBlobStorage

return storageAccountServiceSupportLevel{
Expand Down
181 changes: 181 additions & 0 deletions internal/services/storage/storage_account_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,50 @@ func TestAccStorageAccount_invalidAccountKindForAccessTier(t *testing.T) {
})
}

func TestAccStorageAccount_StorageV1_blobProperties(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_storage_account", "test")
r := StorageAccountResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.storageV1BlobProperties(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func TestAccStorageAccount_StorageV1_queueProperties(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_storage_account", "test")
r := StorageAccountResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.storageV1QueueProperties(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func TestAccStorageAccount_StorageV1_shareProperties(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_storage_account", "test")
r := StorageAccountResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.storageV1ShareProperties(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}
func (r StorageAccountResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
id, err := commonids.ParseStorageAccountID(state.ID)
if err != nil {
Expand Down Expand Up @@ -4702,3 +4746,140 @@ resource "azurerm_storage_account" "test" {
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
}

func (r StorageAccountResource) storageV1BlobProperties(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestAzureRMSA-%d"
location = "%s"
}
resource "azurerm_storage_account" "test" {
name = "unlikely23exst2acct%s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
account_kind = "Storage"
account_tier = "Standard"
account_replication_type = "LRS"
blob_properties {
cors_rule {
allowed_origins = ["http://www.example.com"]
exposed_headers = ["x-tempo-*"]
allowed_headers = ["x-tempo-*"]
allowed_methods = ["GET", "PUT", "PATCH"]
max_age_in_seconds = "500"
}
delete_retention_policy {
days = 300
}
default_service_version = "2019-07-07"
container_delete_retention_policy {
days = 7
}
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
}

func (r StorageAccountResource) storageV1QueueProperties(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-storage-%d"
location = "%s"
}
resource "azurerm_storage_account" "test" {
name = "unlikely23exst2acct%s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
account_kind = "Storage"
account_tier = "Standard"
account_replication_type = "LRS"
queue_properties {
cors_rule {
allowed_origins = ["http://www.example.com"]
exposed_headers = ["x-tempo-*"]
allowed_headers = ["x-tempo-*"]
allowed_methods = ["GET", "PUT"]
max_age_in_seconds = "500"
}
logging {
version = "1.0"
delete = true
read = true
write = true
retention_policy_days = 7
}
hour_metrics {
version = "1.0"
enabled = false
retention_policy_days = 7
}
minute_metrics {
version = "1.0"
enabled = false
retention_policy_days = 7
}
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
}

func (r StorageAccountResource) storageV1ShareProperties(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-storage-%d"
location = "%s"
}
resource "azurerm_storage_account" "test" {
name = "unlikely23exst2acct%s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
account_kind = "Storage"
account_tier = "Standard"
account_replication_type = "LRS"
share_properties {
cors_rule {
allowed_origins = ["http://www.example.com"]
exposed_headers = ["x-tempo-*"]
allowed_headers = ["x-tempo-*"]
allowed_methods = ["GET", "PUT", "PATCH"]
max_age_in_seconds = "500"
}
retention_policy {
days = 300
}
smb {
versions = ["SMB3.0"]
authentication_types = ["NTLMv2"]
kerberos_ticket_encryption_type = ["AES-256"]
}
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
}
4 changes: 3 additions & 1 deletion website/docs/r/storage_account.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,16 @@ The following arguments are supported:

* `queue_properties` - (Optional) A `queue_properties` block as defined below.

~> **NOTE:** `queue_properties` cannot be set when the `account_kind` is set to `BlobStorage`
~> **NOTE:** `queue_properties` can only be configured when `account_tier` is set to `Standard` and `account_kind` is set to either `Storage` or `StorageV2`.

* `static_website` - (Optional) A `static_website` block as defined below.

~> **NOTE:** `static_website` can only be set when the `account_kind` is set to `StorageV2` or `BlockBlobStorage`.

* `share_properties` - (Optional) A `share_properties` block as defined below.

~> **NOTE:** `share_properties` can only be configured when either `account_tier` is `Standard` and `account_kind` is either `Storage` or `StorageV2` - or when `account_tier` is `Premium` and `account_kind` is `FileStorage`.

* `network_rules` - (Optional) A `network_rules` block as documented below.

* `large_file_share_enabled` - (Optional) Is Large File Share Enabled?
Expand Down

0 comments on commit 0777434

Please sign in to comment.