Skip to content

Commit

Permalink
azurerm_storage_account - Support RAGZRS and GZRS `account_replicat…
Browse files Browse the repository at this point in the history
…ion_type` (hashicorp#7080)

Fixes hashicorp#7051
  • Loading branch information
lrxtom2 authored and pbrit committed May 31, 2020
1 parent 5ec743f commit c944974
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 1 deletion.
Expand Up @@ -95,6 +95,8 @@ func resourceArmStorageAccount() *schema.Resource {
"ZRS",
"GRS",
"RAGRS",
"GZRS",
"RAGZRS",
}, true),
DiffSuppressFunc: suppress.CaseDifference,
},
Expand Down
Expand Up @@ -648,6 +648,33 @@ func TestAccAzureRMStorageAccount_staticWebsiteProperties(t *testing.T) {
})
}

func TestAccAzureRMStorageAccount_replicationTypeGZRS(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_storage_account", "test")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acceptance.PreCheck(t) },
Providers: acceptance.SupportedProviders,
CheckDestroy: testCheckAzureRMStorageAccountDestroy,
Steps: []resource.TestStep{
{
Config: testAccAzureRMStorageAccount_replicationTypeGZRS(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMStorageAccountExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "account_replication_type", "GZRS"),
),
},
data.ImportStep(),
{
Config: testAccAzureRMStorageAccount_replicationTypeRAGZRS(data),
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMStorageAccountExists(data.ResourceName),
resource.TestCheckResourceAttr(data.ResourceName, "account_replication_type", "RAGZRS"),
),
},
},
})
}

func testCheckAzureRMStorageAccountExists(resourceName string) resource.TestCheckFunc {
return func(s *terraform.State) error {
// Ensure resource group exists in API
Expand Down Expand Up @@ -1674,3 +1701,47 @@ resource "azurerm_storage_account" "test" {
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
}

func testAccAzureRMStorageAccount_replicationTypeGZRS(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_tier = "Standard"
account_replication_type = "GZRS"
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
}

func testAccAzureRMStorageAccount_replicationTypeRAGZRS(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_tier = "Standard"
account_replication_type = "RAGZRS"
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
}
2 changes: 1 addition & 1 deletion website/docs/r/storage_account.html.markdown
Expand Up @@ -90,7 +90,7 @@ The following arguments are supported:

* `account_tier` - (Required) Defines the Tier to use for this storage account. Valid options are `Standard` and `Premium`. For `BlockBlobStorage` and `FileStorage` accounts only `Premium` is valid. Changing this forces a new resource to be created.

* `account_replication_type` - (Required) Defines the type of replication to use for this storage account. Valid options are `LRS`, `GRS`, `RAGRS` and `ZRS`.
* `account_replication_type` - (Required) Defines the type of replication to use for this storage account. Valid options are `LRS`, `GRS`, `RAGRS`, `ZRS`, `GZRS` and `RAGZRS`.

* `access_tier` - (Optional) Defines the access tier for `BlobStorage`, `FileStorage` and `StorageV2` accounts. Valid options are `Hot` and `Cool`, defaults to `Hot`.

Expand Down

0 comments on commit c944974

Please sign in to comment.