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: the account_kind property now supports FileStorage #3750

Merged
merged 6 commits into from
Jul 3, 2019
Merged
Show file tree
Hide file tree
Changes from 4 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
8 changes: 8 additions & 0 deletions azurerm/resource_arm_storage_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func resourceArmStorageAccount() *schema.Resource {
ValidateFunc: validation.StringInSlice([]string{
string(storage.Storage),
string(storage.BlobStorage),
string(storage.FileStorage),
string(storage.StorageV2),
}, true),
Default: string(storage.Storage),
Expand Down Expand Up @@ -518,6 +519,13 @@ func resourceArmStorageAccountCreate(d *schema.ResourceData, meta interface{}) e
}
}

// AccountTier must be Premium for FileStorage
if accountKind == string(storage.FileStorage) {
if string(parameters.Sku.Tier) == string(storage.StandardLRS) {
return fmt.Errorf("A `account_tier` of `Standard` is not supported for FileStorage accounts.")
}
}

// Create
future, err := client.Create(ctx, resourceGroupName, storageAccountName, parameters)
if err != nil {
Expand Down
85 changes: 85 additions & 0 deletions azurerm/resource_arm_storage_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,44 @@ func TestAccAzureRMStorageAccount_blobStorageWithUpdate(t *testing.T) {
},
})
}
func TestAccAzureRMStorageAccount_fileStorageWithUpdate(t *testing.T) {
resourceName := "azurerm_storage_account.testsa"
ri := tf.AccRandTimeInt()
rs := acctest.RandString(4)
location := testLocation()
preConfig := testAccAzureRMStorageAccount_fileStorage(ri, rs, location)
postConfig := testAccAzureRMStorageAccount_fileStorageUpdate(ri, rs, location)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMStorageAccountDestroy,
Steps: []resource.TestStep{
{
Config: preConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMStorageAccountExists(resourceName),
resource.TestCheckResourceAttr("azurerm_storage_account.testsa", "account_kind", "FileStorage"),
resource.TestCheckResourceAttr("azurerm_storage_account.testsa", "account_tier", "Premium"),
resource.TestCheckResourceAttr("azurerm_storage_account.testsa", "access_tier", "Hot"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
{
Config: postConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMStorageAccountExists(resourceName),
resource.TestCheckResourceAttr("azurerm_storage_account.testsa", "account_tier", "Premium"),
resource.TestCheckResourceAttr("azurerm_storage_account.testsa", "access_tier", "Cool"),
),
},
},
})
}
func TestAccAzureRMStorageAccount_storageV2WithUpdate(t *testing.T) {
resourceName := "azurerm_storage_account.testsa"
ri := tf.AccRandTimeInt()
Expand Down Expand Up @@ -982,6 +1019,54 @@ resource "azurerm_storage_account" "testsa" {
`, rInt, location, rString)
}

func testAccAzureRMStorageAccount_fileStorage(rInt int, rString string, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "testrg" {
name = "acctestAzureRMSA-%d"
location = "%s"
}

resource "azurerm_storage_account" "testsa" {
name = "unlikely23exst2acct%s"
resource_group_name = "${azurerm_resource_group.testrg.name}"

location = "${azurerm_resource_group.testrg.location}"
account_kind = "FileStorage"
account_tier = "Premium"
account_replication_type = "LRS"
access_tier = "Hot"

tags = {
environment = "production"
}
}
`, rInt, location, rString)
}

func testAccAzureRMStorageAccount_fileStorageUpdate(rInt int, rString string, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "testrg" {
name = "acctestAzureRMSA-%d"
location = "%s"
}

resource "azurerm_storage_account" "testsa" {
name = "unlikely23exst2acct%s"
resource_group_name = "${azurerm_resource_group.testrg.name}"

location = "${azurerm_resource_group.testrg.location}"
account_kind = "FileStorage"
account_tier = "Premium"
account_replication_type = "LRS"
access_tier = "Cool"

tags = {
environment = "production"
}
}
`, rInt, location, rString)
}

func testAccAzureRMStorageAccount_storageV2(rInt int, rString string, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "testrg" {
Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/storage_account.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ The following arguments are supported:
resource exists. Changing this forces a new resource to be created.

* `account_kind` - (Optional) Defines the Kind of account. Valid options are `Storage`,
`StorageV2` and `BlobStorage`. Changing this forces a new resource to be created.
`StorageV2`, `BlobStorage`, and `FileStorage`. Changing this forces a new resource to be created.
Defaults to `Storage`.

* `account_tier` - (Required) Defines the Tier to use for this storage account. Valid options are `Standard` and `Premium`. Changing this forces a new resource to be created
* `account_tier` - (Required) Defines the Tier to use for this storage account. Valid options are `Standard` and `Premium`. For `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`.

Expand Down