Skip to content

Commit

Permalink
Merge pull request #14 from cblackuk/Fix-issue6-Storage-Replication-T…
Browse files Browse the repository at this point in the history
…ypes

Fix issue6 storage replication types
  • Loading branch information
katbyte authored Aug 2, 2018
2 parents 7280d82 + 1d03320 commit cab48ae
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 44 deletions.
13 changes: 7 additions & 6 deletions azurestack/data_source_storage_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ func dataSourceArmStorageAccount() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},

"access_tier": {
Type: schema.TypeString,
Computed: true,
},
// currently not supported on Azure Stack
// "access_tier": {
// Type: schema.TypeString,
// Computed: true,
// },

"account_encryption_source": {
Type: schema.TypeString,
Expand Down Expand Up @@ -197,7 +197,8 @@ func dataSourceArmStorageAccountRead(d *schema.ResourceData, meta interface{}) e
}

if props := resp.AccountProperties; props != nil {
d.Set("access_tier", props.AccessTier)
// Currently not supported on Azure Stack
// d.Set("access_tier", props.AccessTier)

// Not supported for 2017-03-09 profile
// d.Set("enable_https_traffic_only", props.EnableHTTPSTrafficOnly)
Expand Down
49 changes: 26 additions & 23 deletions azurestack/resource_arm_storage_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,17 @@ func resourceArmStorageAccount() *schema.Resource {
},

// Only valid for BlobStorage accounts, defaults to "Hot" in create function
"access_tier": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{
string(storage.Cool),
string(storage.Hot),
}, true),
},
// Currently not supported in Azure Stack to create anything but "Storage" v1
// This type does not allow you to select Hot or Cold storage options
// "access_tier": {
// Type: schema.TypeString,
// Optional: true,
// Computed: true,
// ValidateFunc: validation.StringInSlice([]string{
// string(storage.Cool),
// string(storage.Hot),
// }, true),
// },

// Constants not in 2017-03-09 profile
"account_encryption_source": {
Expand Down Expand Up @@ -351,22 +353,22 @@ func resourceArmStorageAccountUpdate(d *schema.ResourceData, meta interface{}) e
d.SetPartial("account_replication_type")
}

if d.HasChange("access_tier") {
accessTier := d.Get("access_tier").(string)
// if d.HasChange("access_tier") {
// accessTier := d.Get("access_tier").(string)

opts := storage.AccountUpdateParameters{
AccountPropertiesUpdateParameters: &storage.AccountPropertiesUpdateParameters{
AccessTier: storage.AccessTier(accessTier),
},
}
// opts := storage.AccountUpdateParameters{
// AccountPropertiesUpdateParameters: &storage.AccountPropertiesUpdateParameters{
// AccessTier: storage.AccessTier(accessTier),
// },
// }

_, err := client.Update(ctx, resourceGroupName, storageAccountName, opts)
if err != nil {
return fmt.Errorf("Error updating Azure Storage Account access_tier %q: %+v", storageAccountName, err)
}
// _, err := client.Update(ctx, resourceGroupName, storageAccountName, opts)
// if err != nil {
// return fmt.Errorf("Error updating Azure Storage Account access_tier %q: %+v", storageAccountName, err)
// }

d.SetPartial("access_tier")
}
// d.SetPartial("access_tier")
// }

if d.HasChange("tags") {
tags := d.Get("tags").(map[string]interface{})
Expand Down Expand Up @@ -468,7 +470,8 @@ func resourceArmStorageAccountRead(d *schema.ResourceData, meta interface{}) err
}

if props := resp.AccountProperties; props != nil {
d.Set("access_tier", props.AccessTier)
// Currently not supported on Azure Stack
// d.Set("access_tier", props.AccessTier)

if customDomain := props.CustomDomain; customDomain != nil {
if err := d.Set("custom_domain", flattenStorageAccountCustomDomain(customDomain)); err != nil {
Expand Down
10 changes: 4 additions & 6 deletions azurestack/resource_arm_storage_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,15 @@ func TestAccAzureStackStorageAccount_blobStorageWithUpdate(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testCheckAzureStackStorageAccountExists("azurestack_storage_account.testsa"),
resource.TestCheckResourceAttr("azurestack_storage_account.testsa", "account_kind", "BlobStorage"),
resource.TestCheckResourceAttr("azurestack_storage_account.testsa", "access_tier", "Hot"),
// resource.TestCheckResourceAttr("azurestack_storage_account.testsa", "access_tier", "Hot"),
),
},

{
Config: postConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureStackStorageAccountExists("azurestack_storage_account.testsa"),
resource.TestCheckResourceAttr("azurestack_storage_account.testsa", "access_tier", "Cool"),
// resource.TestCheckResourceAttr("azurestack_storage_account.testsa", "access_tier", "Cool"),
),
},
},
Expand Down Expand Up @@ -327,15 +327,15 @@ func TestAccAzureStackStorageAccount_storageV2WithUpdate(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testCheckAzureStackStorageAccountExists("azurestack_storage_account.testsa"),
resource.TestCheckResourceAttr("azurestack_storage_account.testsa", "account_kind", "StorageV2"),
resource.TestCheckResourceAttr("azurestack_storage_account.testsa", "access_tier", "Hot"),
// resource.TestCheckResourceAttr("azurestack_storage_account.testsa", "access_tier", "Hot"),
),
},

{
Config: postConfig,
Check: resource.ComposeTestCheckFunc(
testCheckAzureStackStorageAccountExists("azurestack_storage_account.testsa"),
resource.TestCheckResourceAttr("azurestack_storage_account.testsa", "access_tier", "Cool"),
// resource.TestCheckResourceAttr("azurestack_storage_account.testsa", "access_tier", "Cool"),
),
},
},
Expand Down Expand Up @@ -687,7 +687,6 @@ resource "azurestack_storage_account" "testsa" {
account_kind = "BlobStorage"
account_tier = "Standard"
account_replication_type = "LRS"
access_tier = "Cool"
tags {
environment = "production"
Expand Down Expand Up @@ -734,7 +733,6 @@ resource "azurestack_storage_account" "testsa" {
account_kind = "StorageV2"
account_tier = "Standard"
account_replication_type = "LRS"
access_tier = "Cool"
tags {
environment = "production"
Expand Down
8 changes: 6 additions & 2 deletions website/docs/d/storage_account.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,17 @@ output "storage_account_tier" {

* `location` - The Azure location where the Storage Account exists

* `account_kind` - Defines the Kind of account, either `BlobStorage` or `Storage`.
* `account_kind` - (Optional) Defines the Kind of account. Valid option is `Storage`.
. Changing this forces a new resource to be created.
Defaults to `Storage` currently as per [Azure Stack Storage Differences](https://docs.microsoft.com/en-us/azure/azure-stack/user/azure-stack-acs-differences)

* `account_tier` - Defines the Tier of this storage account.

* `account_replication_type` - Defines the type of replication used for this storage account.

* `access_tier` - Defines the access tier for `BlobStorage` accounts.
* `access_tier` - (Required for `BlobStorage` accounts) Defines the access tier
for `BlobStorage` accounts. Valid options are `Hot` and `Cold`, defaults to
`Hot`. - **`Currently Not Supported on Azure Stack`**

* `account_encryption_source` - The Encryption Source for this Storage Account.

Expand Down
14 changes: 7 additions & 7 deletions website/docs/r/storage_account.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ resource "azurestack_storage_account" "testsa" {
resource_group_name = "${azurestack_resource_group.testrg.name}"
location = "westus"
account_tier = "Standard"
account_replication_type = "GRS"
account_replication_type = "LRS"
tags {
environment = "staging"
Expand All @@ -45,17 +45,17 @@ The following arguments are supported:
* `location` - (Required) Specifies the supported Azure location where the
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.
Defaults to `Storage`.
* `account_kind` - (Optional) Defines the Kind of account. Valid option is `Storage`.
. Changing this forces a new resource to be created.
Defaults to `Storage` currently as per [Azure Stack Storage Differences](https://docs.microsoft.com/en-us/azure/azure-stack/user/azure-stack-acs-differences)

* `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`. Changing this forces a new resource to be created - **`Can be provisioned, but no performance limit or guarantee.`**

* `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 option is `LRS` currently as per [Azure Stack Storage Differences](https://docs.microsoft.com/en-us/azure/azure-stack/user/azure-stack-acs-differences)

* `access_tier` - (Required for `BlobStorage` accounts) Defines the access tier
for `BlobStorage` accounts. Valid options are `Hot` and `Cold`, defaults to
`Hot`.
`Hot`. - **`Currently Not Supported on Azure Stack`**

* `account_encryption_source` - (Optional) The Encryption Source for this Storage Account. Possible values are `Microsoft.Keyvault` and `Microsoft.Storage`. Defaults to `Microsoft.Storage`.

Expand Down

0 comments on commit cab48ae

Please sign in to comment.