From 502bfccc867bfd652f02218491a132d7ebf4fedc Mon Sep 17 00:00:00 2001 From: catriona-m <86247157+catriona-m@users.noreply.github.com> Date: Fri, 1 Apr 2022 17:28:33 +0100 Subject: [PATCH] update validation to allow superuser value (#16215) --- ...rage_data_lake_gen2_filesystem_resource.go | 4 +- ...data_lake_gen2_filesystem_resource_test.go | 39 +++++++++++++++++++ ...ge_data_lake_gen2_filesystem.html.markdown | 4 +- 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/internal/services/storage/storage_data_lake_gen2_filesystem_resource.go b/internal/services/storage/storage_data_lake_gen2_filesystem_resource.go index ad0209e88a601..3668080782228 100644 --- a/internal/services/storage/storage_data_lake_gen2_filesystem_resource.go +++ b/internal/services/storage/storage_data_lake_gen2_filesystem_resource.go @@ -79,14 +79,14 @@ func resourceStorageDataLakeGen2FileSystem() *pluginsdk.Resource { Type: pluginsdk.TypeString, Optional: true, Computed: true, - ValidateFunc: validation.IsUUID, + ValidateFunc: validation.Any(validation.IsUUID, validation.StringInSlice([]string{"$superuser"}, false)), }, "group": { Type: pluginsdk.TypeString, Optional: true, Computed: true, - ValidateFunc: validation.IsUUID, + ValidateFunc: validation.Any(validation.IsUUID, validation.StringInSlice([]string{"$superuser"}, false)), }, "ace": { diff --git a/internal/services/storage/storage_data_lake_gen2_filesystem_resource_test.go b/internal/services/storage/storage_data_lake_gen2_filesystem_resource_test.go index f0104cb3e192d..b609f592fc736 100644 --- a/internal/services/storage/storage_data_lake_gen2_filesystem_resource_test.go +++ b/internal/services/storage/storage_data_lake_gen2_filesystem_resource_test.go @@ -128,6 +128,21 @@ func TestAccStorageDataLakeGen2FileSystem_withOwnerGroup(t *testing.T) { }) } +func TestAccStorageDataLakeGen2FileSystem_withSuperUsers(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_storage_data_lake_gen2_filesystem", "test") + r := StorageDataLakeGen2FileSystemResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.withSuperUsers(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func (r StorageDataLakeGen2FileSystemResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { id, err := filesystems.ParseResourceID(state.ID) if err != nil { @@ -340,3 +355,27 @@ resource "azurerm_storage_data_lake_gen2_filesystem" "test" { } `, template, data.RandomInteger) } + +func (r StorageDataLakeGen2FileSystemResource) withSuperUsers(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` +%s + +provider "azuread" {} + +resource "azuread_application" "test" { + display_name = "acctestspa%[2]d" +} + +resource "azuread_service_principal" "test" { + application_id = azuread_application.test.application_id +} + +resource "azurerm_storage_data_lake_gen2_filesystem" "test" { + name = "acctest-%[2]d" + storage_account_id = azurerm_storage_account.test.id + owner = "$superuser" + group = "$superuser" +} +`, template, data.RandomInteger) +} diff --git a/website/docs/r/storage_data_lake_gen2_filesystem.html.markdown b/website/docs/r/storage_data_lake_gen2_filesystem.html.markdown index af29e1ef06d6d..79c945f5da667 100644 --- a/website/docs/r/storage_data_lake_gen2_filesystem.html.markdown +++ b/website/docs/r/storage_data_lake_gen2_filesystem.html.markdown @@ -52,9 +52,9 @@ The following arguments are supported: * `ace` - (Optional) One or more `ace` blocks as defined below to specify the entries for the ACL for the path. -* `owner` - (Optional) Specifies the Object ID of the Azure Active Directory User to make the owning user of the root path (i.e. `/`). +* `owner` - (Optional) Specifies the Object ID of the Azure Active Directory User to make the owning user of the root path (i.e. `/`). Possible values also include `$superuser`. -* `group` - (Optional) Specifies the Object ID of the Azure Active Directory Group to make the owning group of the root path (i.e. `/`). +* `group` - (Optional) Specifies the Object ID of the Azure Active Directory Group to make the owning group of the root path (i.e. `/`). Possible values also include `$superuser`. ~> **NOTE:** The Storage Account requires `account_kind` to be either `StorageV2` or `BlobStorage`. In addition, `is_hns_enabled` has to be set to `true`.