From a1c0bf00b328c04a4779755fbb96847885cc8290 Mon Sep 17 00:00:00 2001 From: Tom Bamford Date: Thu, 18 Jul 2024 21:20:52 +0100 Subject: [PATCH] r/storage_account: set `active_directory` block properties when `directory_type` is specified --- .../storage/storage_account_resource.go | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/internal/services/storage/storage_account_resource.go b/internal/services/storage/storage_account_resource.go index 87f733ae489d..04dbb3fd34cc 100644 --- a/internal/services/storage/storage_account_resource.go +++ b/internal/services/storage/storage_account_resource.go @@ -2530,22 +2530,27 @@ func expandAccountAzureFilesAuthentication(input []interface{}) (*storageaccount output := storageaccounts.AzureFilesIdentityBasedAuthentication{ DirectoryServiceOptions: storageaccounts.DirectoryServiceOptions(v["directory_type"].(string)), } - if output.DirectoryServiceOptions == storageaccounts.DirectoryServiceOptionsAD { + if output.DirectoryServiceOptions == storageaccounts.DirectoryServiceOptionsAD || + output.DirectoryServiceOptions == storageaccounts.DirectoryServiceOptionsAADDS || + output.DirectoryServiceOptions == storageaccounts.DirectoryServiceOptionsAADKERB { ad := expandAccountActiveDirectoryProperties(v["active_directory"].([]interface{})) - if ad == nil { - return nil, fmt.Errorf("`active_directory` is required when `directory_type` is `AD`") - } - if ad.AzureStorageSid == nil { - return nil, fmt.Errorf("`active_directory.0.storage_sid` is required when `directory_type` is `AD`") - } - if ad.DomainSid == nil { - return nil, fmt.Errorf("`active_directory.0.domain_sid` is required when `directory_type` is `AD`") - } - if ad.ForestName == nil { - return nil, fmt.Errorf("`active_directory.0.forest_name` is required when `directory_type` is `AD`") - } - if ad.NetBiosDomainName == nil { - return nil, fmt.Errorf("`active_directory.0.netbios_domain_name` is required when `directory_type` is `AD`") + + if output.DirectoryServiceOptions == storageaccounts.DirectoryServiceOptionsAD { + if ad == nil { + return nil, fmt.Errorf("`active_directory` is required when `directory_type` is `AD`") + } + if ad.AzureStorageSid == nil { + return nil, fmt.Errorf("`active_directory.0.storage_sid` is required when `directory_type` is `AD`") + } + if ad.DomainSid == nil { + return nil, fmt.Errorf("`active_directory.0.domain_sid` is required when `directory_type` is `AD`") + } + if ad.ForestName == nil { + return nil, fmt.Errorf("`active_directory.0.forest_name` is required when `directory_type` is `AD`") + } + if ad.NetBiosDomainName == nil { + return nil, fmt.Errorf("`active_directory.0.netbios_domain_name` is required when `directory_type` is `AD`") + } } output.ActiveDirectoryProperties = ad