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_netapp_volume - support for the zone property #19669

Merged
merged 3 commits into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 6 additions & 6 deletions internal/services/netapp/client/client.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package client

import (
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/capacitypools"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/netappaccounts"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/snapshotpolicy"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/snapshots"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/volumes"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/volumesreplication"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/capacitypools"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/netappaccounts"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/snapshotpolicy"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/snapshots"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/volumes"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/volumesreplication"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/services/netapp/netapp_account_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/netappaccounts"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/netappaccounts"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/netapp/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
Expand Down
2 changes: 1 addition & 1 deletion internal/services/netapp/netapp_account_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/tags"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/netappaccounts"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/netappaccounts"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/helpers/validate"
Expand Down
2 changes: 1 addition & 1 deletion internal/services/netapp/netapp_account_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"testing"

"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/netappaccounts"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/netappaccounts"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down
2 changes: 1 addition & 1 deletion internal/services/netapp/netapp_pool_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/capacitypools"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/capacitypools"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/netapp/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
Expand Down
2 changes: 1 addition & 1 deletion internal/services/netapp/netapp_pool_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/tags"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/capacitypools"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/capacitypools"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down
2 changes: 1 addition & 1 deletion internal/services/netapp/netapp_pool_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"testing"

"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/capacitypools"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/capacitypools"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down
2 changes: 1 addition & 1 deletion internal/services/netapp/netapp_snapshot_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/snapshots"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/snapshots"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/netapp/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/snapshotpolicy"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/snapshotpolicy"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/netapp/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tags"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/tags"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/snapshotpolicy"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/snapshotpolicy"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down
2 changes: 1 addition & 1 deletion internal/services/netapp/netapp_snapshot_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"testing"

"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/snapshotpolicy"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/snapshotpolicy"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down
2 changes: 1 addition & 1 deletion internal/services/netapp/netapp_snapshot_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/snapshots"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/snapshots"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"testing"

"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/snapshots"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/snapshots"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down
12 changes: 11 additions & 1 deletion internal/services/netapp/netapp_volume_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/volumes"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/volumes"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/netapp/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
Expand All @@ -33,6 +33,8 @@ func dataSourceNetAppVolume() *pluginsdk.Resource {

"location": commonschema.LocationComputed(),

"zone": commonschema.ZoneSingleComputed(),

"account_name": {
Type: pluginsdk.TypeString,
Required: true,
Expand Down Expand Up @@ -142,6 +144,14 @@ func dataSourceNetAppVolumeRead(d *pluginsdk.ResourceData, meta interface{}) err
if model := resp.Model; model != nil {
d.Set("location", location.NormalizeNilable(&model.Location))

zone := ""
if model.Zones != nil {
if zones := *model.Zones; len(zones) > 0 {
zone = zones[0]
}
}
d.Set("zone", zone)

props := model.Properties
d.Set("volume_path", props.CreationToken)
d.Set("service_level", props.ServiceLevel)
Expand Down
31 changes: 27 additions & 4 deletions internal/services/netapp/netapp_volume_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/go-azure-helpers/resourcemanager/tags"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/snapshots"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/volumes"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/volumesreplication"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/snapshots"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/volumes"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/volumesreplication"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/helpers/validate"
Expand Down Expand Up @@ -56,6 +56,8 @@ func resourceNetAppVolume() *pluginsdk.Resource {

"location": commonschema.Location(),

"zone": commonschema.ZoneSingleOptionalForceNew(),

"account_name": {
Type: pluginsdk.TypeString,
Required: true,
Expand Down Expand Up @@ -306,6 +308,14 @@ func resourceNetAppVolumeCreate(d *pluginsdk.ResourceData, meta interface{}) err
}

location := azure.NormalizeLocation(d.Get("location").(string))

zones := &[]string{}
if v, ok := d.GetOk("zone"); ok {
zones = &[]string{
v.(string),
}
}

volumePath := d.Get("volume_path").(string)
serviceLevel := volumes.ServiceLevel(d.Get("service_level").(string))
subnetID := d.Get("subnet_id").(string)
Expand Down Expand Up @@ -445,7 +455,8 @@ func resourceNetAppVolumeCreate(d *pluginsdk.ResourceData, meta interface{}) err
AvsDataStore: &avsDataStoreEnabled,
SnapshotDirectoryVisible: utils.Bool(snapshotDirectoryVisible),
},
Tags: tags.Expand(d.Get("tags").(map[string]interface{})),
Tags: tags.Expand(d.Get("tags").(map[string]interface{})),
Zones: zones,
}

if throughputMibps, ok := d.GetOk("throughput_in_mibps"); ok {
Expand Down Expand Up @@ -503,6 +514,10 @@ func resourceNetAppVolumeUpdate(d *pluginsdk.ResourceData, meta interface{}) err
Properties: &volumes.VolumePatchProperties{},
}

if d.HasChange("zones") {
return fmt.Errorf("zone changes are not supported after volume is already created, %s", id)
}

if d.HasChange("storage_quota_in_gb") {
shouldUpdate = true
storageQuotaInBytes := int64(d.Get("storage_quota_in_gb").(int) * 1073741824)
Expand Down Expand Up @@ -585,6 +600,14 @@ func resourceNetAppVolumeRead(d *pluginsdk.ResourceData, meta interface{}) error
if model := resp.Model; model != nil {
d.Set("location", azure.NormalizeLocation(model.Location))

zone := ""
if model.Zones != nil {
if zones := *model.Zones; len(zones) > 0 {
zone = zones[0]
}
}
d.Set("zone", zone)

props := model.Properties
d.Set("volume_path", props.CreationToken)
d.Set("service_level", props.ServiceLevel)
Expand Down
43 changes: 42 additions & 1 deletion internal/services/netapp/netapp_volume_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"regexp"
"testing"

"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2021-10-01/volumes"
"github.com/hashicorp/go-azure-sdk/resource-manager/netapp/2022-05-01/volumes"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand All @@ -32,6 +32,22 @@ func TestAccNetAppVolume_basic(t *testing.T) {
})
}

func TestAccNetAppVolume_availabilityZone(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_netapp_volume", "test")
r := NetAppVolumeResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.availabilityZone(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("zone").HasValue("1"),
),
},
data.ImportStep(),
})
}

func TestAccNetAppVolume_nfsv41(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_netapp_volume", "test")
r := NetAppVolumeResource{}
Expand Down Expand Up @@ -295,6 +311,31 @@ resource "azurerm_netapp_volume" "test" {
`, template, data.RandomInteger, data.RandomInteger)
}

func (NetAppVolumeResource) availabilityZone(data acceptance.TestData) string {
template := NetAppVolumeResource{}.template(data)
return fmt.Sprintf(`
%s

resource "azurerm_netapp_volume" "test" {
name = "acctest-NetAppVolume-%d"
location = azurerm_resource_group.test.location
zone = "1"
resource_group_name = azurerm_resource_group.test.name
account_name = azurerm_netapp_account.test.name
pool_name = azurerm_netapp_pool.test.name
volume_path = "my-unique-file-path-%d"
service_level = "Standard"
subnet_id = azurerm_subnet.test.id
storage_quota_in_gb = 100

tags = {
"CreatedOnDate" = "2022-07-08T23:50:21Z",
"SkipASMAzSecPack" = "true"
}
}
`, template, data.RandomInteger, data.RandomInteger)
}

func (NetAppVolumeResource) nfsv41(data acceptance.TestData) string {
template := NetAppVolumeResource{}.template(data)
return fmt.Sprintf(`
Expand Down

This file was deleted.

This file was deleted.

Loading