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

resource/aws_fsx_windows_file_system: Prevent panic when update includes self_managed_active_directory settings #12630

Merged
merged 1 commit into from
Apr 28, 2020
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
2 changes: 1 addition & 1 deletion aws/resource_aws_fsx_windows_file_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ func expandFsxSelfManagedActiveDirectoryConfigurationUpdate(l []interface{}) *fs

data := l[0].(map[string]interface{})
req := &fsx.SelfManagedActiveDirectoryConfigurationUpdates{
DnsIps: expandStringList(data["dns_ips"].([]interface{})),
DnsIps: expandStringSet(data["dns_ips"].(*schema.Set)),
Password: aws.String(data["password"].(string)),
UserName: aws.String(data["username"].(string)),
}
Expand Down
54 changes: 54 additions & 0 deletions aws/resource_aws_fsx_windows_file_system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,43 @@ func TestAccAWSFsxWindowsFileSystem_SelfManagedActiveDirectory(t *testing.T) {
})
}

func TestAccAWSFsxWindowsFileSystem_SelfManagedActiveDirectory_Username(t *testing.T) {
var filesystem fsx.FileSystem
resourceName := "aws_fsx_windows_file_system.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckFsxWindowsFileSystemDestroy,
Steps: []resource.TestStep{
{
Config: testAccAwsFsxWindowsFileSystemConfigSelfManagedActiveDirectoryUsername("Admin"),
Check: resource.ComposeTestCheckFunc(
testAccCheckFsxWindowsFileSystemExists(resourceName, &filesystem),
resource.TestCheckResourceAttr(resourceName, "self_managed_active_directory.#", "1"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"security_group_ids",
"self_managed_active_directory",
"skip_final_backup",
},
},
{
Config: testAccAwsFsxWindowsFileSystemConfigSelfManagedActiveDirectoryUsername("Administrator"),
Check: resource.ComposeTestCheckFunc(
testAccCheckFsxWindowsFileSystemExists(resourceName, &filesystem),
resource.TestCheckResourceAttr(resourceName, "self_managed_active_directory.#", "1"),
),
},
},
})
}

func TestAccAWSFsxWindowsFileSystem_StorageCapacity(t *testing.T) {
var filesystem1, filesystem2 fsx.FileSystem
resourceName := "aws_fsx_windows_file_system.test"
Expand Down Expand Up @@ -827,6 +864,23 @@ resource "aws_fsx_windows_file_system" "test" {
`)
}

func testAccAwsFsxWindowsFileSystemConfigSelfManagedActiveDirectoryUsername(username string) string {
return testAccAwsFsxWindowsFileSystemConfigBase() + fmt.Sprintf(`
resource "aws_fsx_windows_file_system" "test" {
skip_final_backup = true
storage_capacity = 32
subnet_ids = ["${aws_subnet.test1.id}"]
throughput_capacity = 8
self_managed_active_directory {
dns_ips = aws_directory_service_directory.test.dns_ip_addresses
domain_name = aws_directory_service_directory.test.name
password = aws_directory_service_directory.test.password
username = %[1]q
}
}
`, username)
}

func testAccAwsFsxWindowsFileSystemConfigStorageCapacity(storageCapacity int) string {
return testAccAwsFsxWindowsFileSystemConfigBase() + fmt.Sprintf(`
resource "aws_fsx_windows_file_system" "test" {
Expand Down