Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
teowa committed Nov 8, 2023
1 parent aaf3982 commit 7211ad7
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 5 deletions.
4 changes: 2 additions & 2 deletions internal/services/elasticsan/elastic_san_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,11 @@ func (k ElasticSANResource) CustomizeDiff() sdk.ResourceFunc {
}

if oldVal, newVal := metadata.ResourceDiff.GetChange("base_size_in_tib"); newVal.(int) < oldVal.(int) {
return fmt.Errorf("base_size_in_tib cannot be reduced")
return fmt.Errorf("new base_size_in_tib should be greater than the existing one")
}

if oldVal, newVal := metadata.ResourceDiff.GetChange("extended_size_in_tib"); newVal.(int) < oldVal.(int) {
return fmt.Errorf("extended_size_in_tib cannot be reduced")
return fmt.Errorf("new extended_size_in_tib should be greater than the existing one")
}

return nil
Expand Down
52 changes: 52 additions & 0 deletions internal/services/elasticsan/elastic_san_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,35 @@ func TestAccElasticSAN_update(t *testing.T) {
})
}

func TestAccElasticSAN_updateTags(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_elastic_san", "test")
r := ElasticSANTestResource{}

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

func TestAccElasticSAN_reduceBaseSize(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_elastic_san", "test")
r := ElasticSANTestResource{}
Expand Down Expand Up @@ -154,6 +183,29 @@ resource "azurerm_elastic_san" "test" {
`, r.template(data))
}

func (r ElasticSANTestResource) basicWithTags(data acceptance.TestData) string {
return fmt.Sprintf(`
%s
provider "azurerm" {
features {}
}
resource "azurerm_elastic_san" "test" {
name = "acctestes-${var.random_string}"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
base_size_in_tib = 1
sku {
name = "Premium_LRS"
}
tags = {
foo = "bar"
}
}
`, r.template(data))
}

func (r ElasticSANTestResource) zoneWithZRS(data acceptance.TestData) string {
return fmt.Sprintf(`
%s
Expand Down
8 changes: 5 additions & 3 deletions website/docs/r/elastic_san.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ The following arguments are supported:

* `base_size_in_tib` - (Required) Specifies the base size of the Elastic SAN resource in TiB. Possible values are between `1` and `100`.

* `extended_size_in_tib` - (Required) Specifies the extended size of the Elastic SAN resource in TiB. Possible values are between `1` and `100`.

-> **NOTE** `base_size_in_tib` and `extended_size_in_tib` cannot be reduced.
-> **NOTE** When updating `base_size_in_tib`, the new value should be greater than the existing one.

* `sku` - (Required) A `sku` block as defined below.

* `extended_size_in_tib` - (Optional) Specifies the extended size of the Elastic SAN resource in TiB. Possible values are between `1` and `100`.

-> **NOTE** `extended_size_in_tib` cannot be removed and when updating, the new value should be greater than the existing one.

* `zones` - (Optional) Logical zone for the Elastic SAN resource. Changing this forces a new resource to be created.

-> **NOTE** `zones` cannot be specified if `sku.name` is set to `Premium_ZRS`.
Expand Down

0 comments on commit 7211ad7

Please sign in to comment.