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_pool - support for the encryption_type property #24993

Merged
merged 2 commits into from
Feb 27, 2024
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
7 changes: 7 additions & 0 deletions internal/services/netapp/netapp_pool_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"time"

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
Expand Down Expand Up @@ -51,6 +52,11 @@ func dataSourceNetAppPool() *pluginsdk.Resource {
Type: pluginsdk.TypeInt,
Computed: true,
},

"encryption_type": {
Type: pluginsdk.TypeString,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -80,6 +86,7 @@ func dataSourceNetAppPoolRead(d *pluginsdk.ResourceData, meta interface{}) error
d.Set("location", location.NormalizeNilable(&model.Location))
d.Set("service_level", string(model.Properties.ServiceLevel))
d.Set("size_in_tb", model.Properties.Size/1099511627776)
d.Set("encryption_type", string(pointer.From(model.Properties.EncryptionType)))
}

return nil
Expand Down
1 change: 1 addition & 0 deletions internal/services/netapp/netapp_pool_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func TestAccDataSourceNetAppPool_basic(t *testing.T) {
check.That(data.ResourceName).Key("account_name").Exists(),
check.That(data.ResourceName).Key("service_level").Exists(),
check.That(data.ResourceName).Key("size_in_tb").Exists(),
check.That(data.ResourceName).Key("encryption_type").Exists(),
),
},
})
Expand Down
20 changes: 18 additions & 2 deletions internal/services/netapp/netapp_pool_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strconv"
"time"

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/tags"
Expand Down Expand Up @@ -88,6 +89,17 @@ func resourceNetAppPool() *pluginsdk.Resource {
}, false),
},

"encryption_type": {
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
Default: capacitypools.EncryptionTypeSingle,
ValidateFunc: validation.StringInSlice([]string{
string(capacitypools.EncryptionTypeSingle),
string(capacitypools.EncryptionTypeDouble),
}, false),
},

"tags": commonschema.Tags(),
},
}
Expand Down Expand Up @@ -116,11 +128,14 @@ func resourceNetAppPoolCreate(d *pluginsdk.ResourceData, meta interface{}) error
sizeInMB := sizeInTB * 1024 * 1024
sizeInBytes := sizeInMB * 1024 * 1024

encryptionType := capacitypools.EncryptionType(d.Get("encryption_type").(string))

capacityPoolParameters := capacitypools.CapacityPool{
Location: azure.NormalizeLocation(d.Get("location").(string)),
Properties: capacitypools.PoolProperties{
ServiceLevel: capacitypools.ServiceLevel(d.Get("service_level").(string)),
Size: sizeInBytes,
ServiceLevel: capacitypools.ServiceLevel(d.Get("service_level").(string)),
Size: sizeInBytes,
EncryptionType: &encryptionType,
},
Tags: tags.Expand(d.Get("tags").(map[string]interface{})),
}
Expand Down Expand Up @@ -234,6 +249,7 @@ func resourceNetAppPoolRead(d *pluginsdk.ResourceData, meta interface{}) error {
qosType = string(*poolProperties.QosType)
}
d.Set("qos_type", qosType)
d.Set("encryption_type", string(pointer.From(poolProperties.EncryptionType)))

return tags.FlattenAndSet(d, model.Tags)
}
Expand Down
55 changes: 55 additions & 0 deletions internal/services/netapp/netapp_pool_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func TestAccNetAppPool_complete(t *testing.T) {
check.That(data.ResourceName).Key("tags.%").HasValue("2"),
check.That(data.ResourceName).Key("tags.FoO").HasValue("BaR"),
check.That(data.ResourceName).Key("qos_type").HasValue("Auto"),
check.That(data.ResourceName).Key("encryption_type").HasValue("Single"),
),
},
data.ImportStep(),
Expand Down Expand Up @@ -110,6 +111,22 @@ func TestAccNetAppPool_update(t *testing.T) {
})
}

func TestAccNetAppPool_doubleEncryption(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_netapp_pool", "test")
r := NetAppPoolResource{}

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

func (t NetAppPoolResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
id, err := capacitypools.ParseCapacityPoolID(state.ID)
if err != nil {
Expand Down Expand Up @@ -208,6 +225,7 @@ resource "azurerm_netapp_pool" "test" {
service_level = "Standard"
size_in_tb = 15
qos_type = "Auto"
encryption_type = "Single"

tags = {
"CreatedOnDate" = "2022-07-08T23:50:21Z",
Expand Down Expand Up @@ -259,3 +277,40 @@ resource "azurerm_netapp_pool" "test" {
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger)
}

func (NetAppPoolResource) doubleEncryption(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}

resource "azurerm_resource_group" "test" {
name = "acctestRG-netapp-%d"
location = "%s"

tags = {
"SkipNRMSNSG" = "true"
}
}

resource "azurerm_netapp_account" "test" {
name = "acctest-NetAppAccount-%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
}

resource "azurerm_netapp_pool" "test" {
name = "acctest-NetAppPool-%d"
account_name = azurerm_netapp_account.test.name
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
service_level = "Standard"
size_in_tb = 2
encryption_type = "Double"

tags = {
"CreatedOnDate" = "2022-07-08T23:50:21Z",
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger)
}
2 changes: 2 additions & 0 deletions website/docs/d/netapp_pool.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ The following attributes are exported:

* `size_in_tb` - Provisioned size of the pool in TB.

* `encryption_type` - The encryption type of the pool.

---

## Timeouts
Expand Down
4 changes: 3 additions & 1 deletion website/docs/r/netapp_pool.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,16 @@ 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.

* `service_level` - (Required) The service level of the file system. Valid values include `Premium`, `Standard`, or `Ultra`. Changing this forces a new resource to be created.
* `service_level` - (Required) The service level of the file system. Valid values include `Premium`, `Standard`, and `Ultra`. Changing this forces a new resource to be created.

* `size_in_tb` - (Required) Provisioned size of the pool in TB. Value must be between `2` and `500`.

~> **NOTE** `2` TB capacity pool sizing is currently in preview. You can only take advantage of the `2` TB minimum if all the volumes in the capacity pool are using `Standard` network features. If any volume is using `Basic` network features, the minimum size is `4` TB. Please see the product [documentation](https://learn.microsoft.com/azure/azure-netapp-files/azure-netapp-files-set-up-capacity-pool) for more information.

* `qos_type` - (Optional) QoS Type of the pool. Valid values include `Auto` or `Manual`.

* `encryption_type` - (Optional) The encryption type of the pool. Valid values include `Single`, and `Double`. Defaults to `Single`. Changing this forces a new resource to be created.

* `tags` - (Optional) A mapping of tags to assign to the resource.

---
Expand Down
Loading