From 26106af5ae23ebd9ff443c4c38d74c47f2f3b2d2 Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Sat, 4 Apr 2020 16:07:22 +0300 Subject: [PATCH 01/13] add plan time validation to `self_managed_active_directory.dns_ips` add support for multi az deployment --- aws/resource_aws_fsx_windows_file_system.go | 42 +++++++++- ...source_aws_fsx_windows_file_system_test.go | 76 +++++++++++++++++++ 2 files changed, 116 insertions(+), 2 deletions(-) diff --git a/aws/resource_aws_fsx_windows_file_system.go b/aws/resource_aws_fsx_windows_file_system.go index 3c63d346747..4f604397ddd 100644 --- a/aws/resource_aws_fsx_windows_file_system.go +++ b/aws/resource_aws_fsx_windows_file_system.go @@ -104,7 +104,10 @@ func resourceAwsFsxWindowsFileSystem() *schema.Resource { Required: true, MinItems: 1, MaxItems: 2, - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: validation.IsIPAddress, + }, }, "domain_name": { Type: schema.TypeString, @@ -151,7 +154,6 @@ func resourceAwsFsxWindowsFileSystem() *schema.Resource { Required: true, ForceNew: true, MinItems: 1, - MaxItems: 1, Elem: &schema.Schema{Type: schema.TypeString}, }, "tags": tagsSchema(), @@ -174,6 +176,30 @@ func resourceAwsFsxWindowsFileSystem() *schema.Resource { validation.StringMatch(regexp.MustCompile(`^[1-7]:([01]\d|2[0-3]):?([0-5]\d)$`), "must be in the format d:HH:MM"), ), }, + "deployment_type": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Default: fsx.WindowsDeploymentTypeSingleAz1, + ValidateFunc: validation.StringInSlice([]string{ + fsx.WindowsDeploymentTypeMultiAz1, + fsx.WindowsDeploymentTypeSingleAz1, + }, false), + }, + "preferred_subnet_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ForceNew: true, + }, + "preferred_file_server_ip": { + Type: schema.TypeString, + Computed: true, + }, + "remote_administration_endpoint": { + Type: schema.TypeString, + Computed: true, + }, }, } } @@ -197,6 +223,14 @@ func resourceAwsFsxWindowsFileSystemCreate(d *schema.ResourceData, meta interfac input.WindowsConfiguration.ActiveDirectoryId = aws.String(v.(string)) } + if v, ok := d.GetOk("deployment_type"); ok { + input.WindowsConfiguration.DeploymentType = aws.String(v.(string)) + } + + if v, ok := d.GetOk("preferred_subnet_id"); ok { + input.WindowsConfiguration.PreferredSubnetId = aws.String(v.(string)) + } + if v, ok := d.GetOk("daily_automatic_backup_start_time"); ok { input.WindowsConfiguration.DailyAutomaticBackupStartTime = aws.String(v.(string)) } @@ -320,6 +354,10 @@ func resourceAwsFsxWindowsFileSystemRead(d *schema.ResourceData, meta interface{ d.Set("automatic_backup_retention_days", filesystem.WindowsConfiguration.AutomaticBackupRetentionDays) d.Set("copy_tags_to_backups", filesystem.WindowsConfiguration.CopyTagsToBackups) d.Set("daily_automatic_backup_start_time", filesystem.WindowsConfiguration.DailyAutomaticBackupStartTime) + d.Set("deployment_type", filesystem.WindowsConfiguration.DeploymentType) + d.Set("preferred_subnet_id", filesystem.WindowsConfiguration.PreferredSubnetId) + d.Set("preferred_file_server_ip", filesystem.WindowsConfiguration.PreferredFileServerIp) + d.Set("remote_administration_endpoint", filesystem.WindowsConfiguration.RemoteAdministrationEndpoint) d.Set("dns_name", filesystem.DNSName) d.Set("kms_key_id", filesystem.KmsKeyId) diff --git a/aws/resource_aws_fsx_windows_file_system_test.go b/aws/resource_aws_fsx_windows_file_system_test.go index 100627f2189..4721914d926 100644 --- a/aws/resource_aws_fsx_windows_file_system_test.go +++ b/aws/resource_aws_fsx_windows_file_system_test.go @@ -112,6 +112,55 @@ func TestAccAWSFsxWindowsFileSystem_basic(t *testing.T) { "skip_final_backup", }, }, + { + Config: testAccAwsFsxWindowsFileSystemConfigSubnetIds1WithSingleType(), + PlanOnly: true, + }, + }, + }) +} + +func TestAccAWSFsxWindowsFileSystem_multiAz(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: testAccAwsFsxWindowsFileSystemConfigSubnetIds2(), + Check: resource.ComposeTestCheckFunc( + testAccCheckFsxWindowsFileSystemExists(resourceName, &filesystem), + testAccMatchResourceAttrRegionalARN(resourceName, "arn", "fsx", regexp.MustCompile(`file-system/fs-.+`)), + resource.TestCheckResourceAttr(resourceName, "automatic_backup_retention_days", "7"), + resource.TestCheckResourceAttr(resourceName, "copy_tags_to_backups", "false"), + resource.TestMatchResourceAttr(resourceName, "daily_automatic_backup_start_time", regexp.MustCompile(`^\d\d:\d\d$`)), + resource.TestMatchResourceAttr(resourceName, "dns_name", regexp.MustCompile(`fs-.+\..+`)), + resource.TestMatchResourceAttr(resourceName, "kms_key_id", regexp.MustCompile(`^arn:`)), + resource.TestCheckResourceAttr(resourceName, "network_interface_ids.#", "1"), + testAccCheckResourceAttrAccountID(resourceName, "owner_id"), + resource.TestCheckResourceAttr(resourceName, "security_group_ids.#", "0"), + resource.TestCheckResourceAttr(resourceName, "self_managed_active_directory.#", "0"), + resource.TestCheckResourceAttr(resourceName, "skip_final_backup", "true"), + resource.TestCheckResourceAttr(resourceName, "storage_capacity", "32"), + resource.TestCheckResourceAttr(resourceName, "subnet_ids.#", "2"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttr(resourceName, "throughput_capacity", "8"), + resource.TestMatchResourceAttr(resourceName, "vpc_id", regexp.MustCompile(`^vpc-.+`)), + resource.TestMatchResourceAttr(resourceName, "weekly_maintenance_start_time", regexp.MustCompile(`^\d:\d\d:\d\d$`)), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "security_group_ids", + "skip_final_backup", + }, + }, }, }) } @@ -905,6 +954,33 @@ resource "aws_fsx_windows_file_system" "test" { `) } +func testAccAwsFsxWindowsFileSystemConfigSubnetIds1WithSingleType() string { + return testAccAwsFsxWindowsFileSystemConfigBase() + fmt.Sprintf(` +resource "aws_fsx_windows_file_system" "test" { + active_directory_id = "${aws_directory_service_directory.test.id}" + skip_final_backup = true + storage_capacity = 32 + deployment_type = "SINGLE_AZ_1" + subnet_ids = ["${aws_subnet.test1.id}"] + throughput_capacity = 8 +} +`) +} + +func testAccAwsFsxWindowsFileSystemConfigSubnetIds2() string { + return testAccAwsFsxWindowsFileSystemConfigBase() + fmt.Sprintf(` +resource "aws_fsx_windows_file_system" "test" { + active_directory_id = "${aws_directory_service_directory.test.id}" + skip_final_backup = true + storage_capacity = 32 + deployment_type = "MULTI_AZ_1" + subnet_ids = ["${aws_subnet.test1.id}", "${aws_subnet.test2.id}"] + preferred_subnet_id = "${aws_subnet.test1.id}" + throughput_capacity = 8 +} +`) +} + func testAccAwsFsxWindowsFileSystemConfigTags1(tagKey1, tagValue1 string) string { return testAccAwsFsxWindowsFileSystemConfigBase() + fmt.Sprintf(` resource "aws_fsx_windows_file_system" "test" { From 6659700902e85c36dae8a912a1af3388c367fff6 Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Sat, 4 Apr 2020 16:38:15 +0300 Subject: [PATCH 02/13] add deployment type to test --- aws/resource_aws_fsx_windows_file_system_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aws/resource_aws_fsx_windows_file_system_test.go b/aws/resource_aws_fsx_windows_file_system_test.go index 4721914d926..9695f9e86f7 100644 --- a/aws/resource_aws_fsx_windows_file_system_test.go +++ b/aws/resource_aws_fsx_windows_file_system_test.go @@ -101,6 +101,7 @@ func TestAccAWSFsxWindowsFileSystem_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "throughput_capacity", "8"), resource.TestMatchResourceAttr(resourceName, "vpc_id", regexp.MustCompile(`^vpc-.+`)), resource.TestMatchResourceAttr(resourceName, "weekly_maintenance_start_time", regexp.MustCompile(`^\d:\d\d:\d\d$`)), + resource.TestCheckResourceAttr(resourceName, "deployment_type", "SINGLE_AZ_1"), ), }, { @@ -150,6 +151,7 @@ func TestAccAWSFsxWindowsFileSystem_multiAz(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "throughput_capacity", "8"), resource.TestMatchResourceAttr(resourceName, "vpc_id", regexp.MustCompile(`^vpc-.+`)), resource.TestMatchResourceAttr(resourceName, "weekly_maintenance_start_time", regexp.MustCompile(`^\d:\d\d:\d\d$`)), + resource.TestCheckResourceAttr(resourceName, "deployment_type", "MULTI_AZ_1"), ), }, { From f6d15b7958a82c8990fbe5c05614be2c790b6837 Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Sat, 4 Apr 2020 16:40:45 +0300 Subject: [PATCH 03/13] add computed flag to deployment_type --- aws/resource_aws_fsx_windows_file_system.go | 1 + 1 file changed, 1 insertion(+) diff --git a/aws/resource_aws_fsx_windows_file_system.go b/aws/resource_aws_fsx_windows_file_system.go index 4f604397ddd..8a7ade65e61 100644 --- a/aws/resource_aws_fsx_windows_file_system.go +++ b/aws/resource_aws_fsx_windows_file_system.go @@ -179,6 +179,7 @@ func resourceAwsFsxWindowsFileSystem() *schema.Resource { "deployment_type": { Type: schema.TypeString, Optional: true, + Computed: true, ForceNew: true, Default: fsx.WindowsDeploymentTypeSingleAz1, ValidateFunc: validation.StringInSlice([]string{ From dae99398bf5534a6d232e2609854edd8cf4d7476 Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Sat, 4 Apr 2020 17:01:30 +0300 Subject: [PATCH 04/13] add docs --- website/docs/r/fsx_windows_file_system.html.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/website/docs/r/fsx_windows_file_system.html.markdown b/website/docs/r/fsx_windows_file_system.html.markdown index b4e4d95cb64..3c189fa8380 100644 --- a/website/docs/r/fsx_windows_file_system.html.markdown +++ b/website/docs/r/fsx_windows_file_system.html.markdown @@ -65,6 +65,8 @@ The following arguments are supported: * `skip_final_backup` - (Optional) When enabled, will skip the default final backup taken when the file system is deleted. This configuration must be applied separately before attempting to delete the resource to have the desired behavior. Defaults to `false`. * `tags` - (Optional) A map of tags to assign to the file system. * `weekly_maintenance_start_time` - (Optional) The preferred start time (in `d:HH:MM` format) to perform weekly maintenance, in the UTC time zone. +* `deployment_type` - (Optional) Specifies the file system deployment type, valid values are `MULTI_AZ_1` and `SINGLE_AZ_1`. Default values is `SINGLE_AZ_1`. +* `PreferredSubnetId` - (Optional) Specifies the subnet in which you want the preferred file server to be located. Required for when deployment type is `MULTI_AZ_1`. ### self_managed_active_directory @@ -87,6 +89,8 @@ In addition to all arguments above, the following attributes are exported: * `network_interface_ids` - Set of Elastic Network Interface identifiers from which the file system is accessible. * `owner_id` - AWS account identifier that created the file system. * `vpc_id` - Identifier of the Virtual Private Cloud for the file system. +* `preferred_file_server_ip` - the IP address of the primary, or preferred, file server. +* `remote_administration_endpoint` - For `MULTI_AZ_1` deployment types, use this endpoint when performing administrative tasks on the file system using Amazon FSx Remote PowerShell. For `SINGLE_AZ_1` deployment types, this is the DNS name of the file system. ## Timeouts From 704c563d5af1c9aa8dcd2b5b35dcc547e4cce3cd Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Sat, 4 Apr 2020 17:35:15 +0300 Subject: [PATCH 05/13] fix docs --- website/docs/r/fsx_windows_file_system.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/r/fsx_windows_file_system.html.markdown b/website/docs/r/fsx_windows_file_system.html.markdown index 3c189fa8380..8a46472e131 100644 --- a/website/docs/r/fsx_windows_file_system.html.markdown +++ b/website/docs/r/fsx_windows_file_system.html.markdown @@ -53,7 +53,7 @@ resource "aws_fsx_windows_file_system" "example" { The following arguments are supported: * `storage_capacity` - (Required) Storage capacity (GiB) of the file system. Minimum of 32 and maximum of 65536. -* `subnet_ids` - (Required) A list of IDs for the subnets that the file system will be accessible from. File systems support only one subnet. The file server is also launched in that subnet's Availability Zone. +* `subnet_ids` - (Required) A list of IDs for the subnets that the file system will be accessible from. to specify more than a single subnet set `deployment_type` to `MULTI_AZ_1`. * `throughput_capacity` - (Required) Throughput (megabytes per second) of the file system in power of 2 increments. Minimum of `8` and maximum of `2048`. * `active_directory_id` - (Optional) The ID for an existing Microsoft Active Directory instance that the file system should join when it's created. Cannot be specified with `self_managed_active_directory`. * `automatic_backup_retention_days` - (Optional) The number of days to retain automatic backups. Minimum of `0` and maximum of `35`. Defaults to `7`. Set to `0` to disable. @@ -66,7 +66,7 @@ The following arguments are supported: * `tags` - (Optional) A map of tags to assign to the file system. * `weekly_maintenance_start_time` - (Optional) The preferred start time (in `d:HH:MM` format) to perform weekly maintenance, in the UTC time zone. * `deployment_type` - (Optional) Specifies the file system deployment type, valid values are `MULTI_AZ_1` and `SINGLE_AZ_1`. Default values is `SINGLE_AZ_1`. -* `PreferredSubnetId` - (Optional) Specifies the subnet in which you want the preferred file server to be located. Required for when deployment type is `MULTI_AZ_1`. +* `preferred_subnet_id` - (Optional) Specifies the subnet in which you want the preferred file server to be located. Required for when deployment type is `MULTI_AZ_1`. ### self_managed_active_directory From 6ca61d85dcc496c44aaff5699f412a1db16fb4bd Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Sat, 4 Apr 2020 17:40:00 +0300 Subject: [PATCH 06/13] remove computed --- aws/resource_aws_fsx_windows_file_system.go | 1 - 1 file changed, 1 deletion(-) diff --git a/aws/resource_aws_fsx_windows_file_system.go b/aws/resource_aws_fsx_windows_file_system.go index 8a7ade65e61..4f604397ddd 100644 --- a/aws/resource_aws_fsx_windows_file_system.go +++ b/aws/resource_aws_fsx_windows_file_system.go @@ -179,7 +179,6 @@ func resourceAwsFsxWindowsFileSystem() *schema.Resource { "deployment_type": { Type: schema.TypeString, Optional: true, - Computed: true, ForceNew: true, Default: fsx.WindowsDeploymentTypeSingleAz1, ValidateFunc: validation.StringInSlice([]string{ From 2a18ac8e8b198b7b94a10d1f3fa9174ffd57d2fe Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Sat, 4 Apr 2020 19:49:54 +0300 Subject: [PATCH 07/13] fix multi az test --- aws/resource_aws_fsx_windows_file_system_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_fsx_windows_file_system_test.go b/aws/resource_aws_fsx_windows_file_system_test.go index 9695f9e86f7..6b29af7db2f 100644 --- a/aws/resource_aws_fsx_windows_file_system_test.go +++ b/aws/resource_aws_fsx_windows_file_system_test.go @@ -138,11 +138,10 @@ func TestAccAWSFsxWindowsFileSystem_multiAz(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "automatic_backup_retention_days", "7"), resource.TestCheckResourceAttr(resourceName, "copy_tags_to_backups", "false"), resource.TestMatchResourceAttr(resourceName, "daily_automatic_backup_start_time", regexp.MustCompile(`^\d\d:\d\d$`)), - resource.TestMatchResourceAttr(resourceName, "dns_name", regexp.MustCompile(`fs-.+\..+`)), + resource.TestMatchResourceAttr(resourceName, "dns_name", regexp.MustCompile(`^amznfsx\w{8}\.corp\.notexample\.com$`)), resource.TestMatchResourceAttr(resourceName, "kms_key_id", regexp.MustCompile(`^arn:`)), - resource.TestCheckResourceAttr(resourceName, "network_interface_ids.#", "1"), + resource.TestCheckResourceAttr(resourceName, "network_interface_ids.#", "2"), testAccCheckResourceAttrAccountID(resourceName, "owner_id"), - resource.TestCheckResourceAttr(resourceName, "security_group_ids.#", "0"), resource.TestCheckResourceAttr(resourceName, "self_managed_active_directory.#", "0"), resource.TestCheckResourceAttr(resourceName, "skip_final_backup", "true"), resource.TestCheckResourceAttr(resourceName, "storage_capacity", "32"), From 64d2b9aad254d26caa8c07b36f48a003b4100b4d Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Fri, 22 May 2020 11:32:32 +0300 Subject: [PATCH 08/13] disappears --- ...source_aws_fsx_windows_file_system_test.go | 20 +------------------ 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/aws/resource_aws_fsx_windows_file_system_test.go b/aws/resource_aws_fsx_windows_file_system_test.go index 6b29af7db2f..42e5e03fc39 100644 --- a/aws/resource_aws_fsx_windows_file_system_test.go +++ b/aws/resource_aws_fsx_windows_file_system_test.go @@ -179,7 +179,7 @@ func TestAccAWSFsxWindowsFileSystem_disappears(t *testing.T) { Config: testAccAwsFsxWindowsFileSystemConfigSubnetIds1(), Check: resource.ComposeTestCheckFunc( testAccCheckFsxWindowsFileSystemExists(resourceName, &filesystem), - testAccCheckFsxWindowsFileSystemDisappears(&filesystem), + testAccCheckResourceDisappears(testAccProvider, resourceAwsFsxWindowsFileSystem(), resourceName), ), ExpectNonEmptyPlan: true, }, @@ -659,24 +659,6 @@ func testAccCheckFsxWindowsFileSystemDestroy(s *terraform.State) error { return nil } -func testAccCheckFsxWindowsFileSystemDisappears(filesystem *fsx.FileSystem) resource.TestCheckFunc { - return func(s *terraform.State) error { - conn := testAccProvider.Meta().(*AWSClient).fsxconn - - input := &fsx.DeleteFileSystemInput{ - FileSystemId: filesystem.FileSystemId, - } - - _, err := conn.DeleteFileSystem(input) - - if err != nil { - return err - } - - return waitForFsxFileSystemDeletion(conn, aws.StringValue(filesystem.FileSystemId), 30*time.Minute) - } -} - func testAccCheckFsxWindowsFileSystemNotRecreated(i, j *fsx.FileSystem) resource.TestCheckFunc { return func(s *terraform.State) error { if aws.StringValue(i.FileSystemId) != aws.StringValue(j.FileSystemId) { From 85dc3abb0ac62ddc3f9645fc99a502d48c65b649 Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Mon, 20 Jul 2020 13:32:41 +0300 Subject: [PATCH 09/13] fix lint issue --- aws/resource_aws_fsx_windows_file_system_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws/resource_aws_fsx_windows_file_system_test.go b/aws/resource_aws_fsx_windows_file_system_test.go index 42e5e03fc39..93784a0dc90 100644 --- a/aws/resource_aws_fsx_windows_file_system_test.go +++ b/aws/resource_aws_fsx_windows_file_system_test.go @@ -139,7 +139,7 @@ func TestAccAWSFsxWindowsFileSystem_multiAz(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "copy_tags_to_backups", "false"), resource.TestMatchResourceAttr(resourceName, "daily_automatic_backup_start_time", regexp.MustCompile(`^\d\d:\d\d$`)), resource.TestMatchResourceAttr(resourceName, "dns_name", regexp.MustCompile(`^amznfsx\w{8}\.corp\.notexample\.com$`)), - resource.TestMatchResourceAttr(resourceName, "kms_key_id", regexp.MustCompile(`^arn:`)), + testAccMatchResourceAttrRegionalARN(resourceName, "kms_key_id", "kms", regexp.MustCompile(`key/.+`)), resource.TestCheckResourceAttr(resourceName, "network_interface_ids.#", "2"), testAccCheckResourceAttrAccountID(resourceName, "owner_id"), resource.TestCheckResourceAttr(resourceName, "self_managed_active_directory.#", "0"), From 2792142efe838cfe011fc533898eca4bd5e381ac Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Tue, 21 Jul 2020 12:20:31 +0300 Subject: [PATCH 10/13] add support for `SINGLE_AZ_2` type --- aws/resource_aws_fsx_windows_file_system.go | 1 + ...source_aws_fsx_windows_file_system_test.go | 58 +++++++++++++++++-- 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/aws/resource_aws_fsx_windows_file_system.go b/aws/resource_aws_fsx_windows_file_system.go index 4f604397ddd..a45d7308d64 100644 --- a/aws/resource_aws_fsx_windows_file_system.go +++ b/aws/resource_aws_fsx_windows_file_system.go @@ -184,6 +184,7 @@ func resourceAwsFsxWindowsFileSystem() *schema.Resource { ValidateFunc: validation.StringInSlice([]string{ fsx.WindowsDeploymentTypeMultiAz1, fsx.WindowsDeploymentTypeSingleAz1, + fsx.WindowsDeploymentTypeSingleAz2, }, false), }, "preferred_subnet_id": { diff --git a/aws/resource_aws_fsx_windows_file_system_test.go b/aws/resource_aws_fsx_windows_file_system_test.go index 93784a0dc90..46ef16f3ea7 100644 --- a/aws/resource_aws_fsx_windows_file_system_test.go +++ b/aws/resource_aws_fsx_windows_file_system_test.go @@ -99,7 +99,7 @@ func TestAccAWSFsxWindowsFileSystem_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "subnet_ids.#", "1"), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttr(resourceName, "throughput_capacity", "8"), - resource.TestMatchResourceAttr(resourceName, "vpc_id", regexp.MustCompile(`^vpc-.+`)), + resource.TestCheckResourceAttrPair(resourceName, "vpc_id", "aws_vpc.test", "id"), resource.TestMatchResourceAttr(resourceName, "weekly_maintenance_start_time", regexp.MustCompile(`^\d:\d\d:\d\d$`)), resource.TestCheckResourceAttr(resourceName, "deployment_type", "SINGLE_AZ_1"), ), @@ -114,13 +114,59 @@ func TestAccAWSFsxWindowsFileSystem_basic(t *testing.T) { }, }, { - Config: testAccAwsFsxWindowsFileSystemConfigSubnetIds1WithSingleType(), + Config: testAccAwsFsxWindowsFileSystemConfigSubnetIds1WithSingleType("SINGLE_AZ_1"), PlanOnly: true, }, }, }) } +func TestAccAWSFsxWindowsFileSystem_singleAz2(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: testAccAwsFsxWindowsFileSystemConfigSubnetIds1WithSingleType("SINGLE_AZ_2"), + Check: resource.ComposeTestCheckFunc( + testAccCheckFsxWindowsFileSystemExists(resourceName, &filesystem), + testAccMatchResourceAttrRegionalARN(resourceName, "arn", "fsx", regexp.MustCompile(`file-system/fs-.+`)), + resource.TestCheckResourceAttr(resourceName, "automatic_backup_retention_days", "7"), + resource.TestCheckResourceAttr(resourceName, "copy_tags_to_backups", "false"), + resource.TestMatchResourceAttr(resourceName, "daily_automatic_backup_start_time", regexp.MustCompile(`^\d\d:\d\d$`)), + resource.TestMatchResourceAttr(resourceName, "dns_name", regexp.MustCompile(`^amznfsx\w{8}\.corp\.notexample\.com$`)), + testAccMatchResourceAttrRegionalARN(resourceName, "kms_key_id", "kms", regexp.MustCompile(`key/.+`)), + resource.TestCheckResourceAttr(resourceName, "network_interface_ids.#", "1"), + testAccCheckResourceAttrAccountID(resourceName, "owner_id"), + resource.TestCheckResourceAttr(resourceName, "security_group_ids.#", "0"), + resource.TestCheckResourceAttr(resourceName, "self_managed_active_directory.#", "0"), + resource.TestCheckResourceAttr(resourceName, "skip_final_backup", "true"), + resource.TestCheckResourceAttr(resourceName, "storage_capacity", "32"), + resource.TestCheckResourceAttr(resourceName, "subnet_ids.#", "1"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttr(resourceName, "throughput_capacity", "8"), + resource.TestCheckResourceAttrPair(resourceName, "vpc_id", "aws_vpc.test", "id"), + resource.TestMatchResourceAttr(resourceName, "weekly_maintenance_start_time", regexp.MustCompile(`^\d:\d\d:\d\d$`)), + resource.TestCheckResourceAttr(resourceName, "deployment_type", "SINGLE_AZ_2"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "security_group_ids", + "skip_final_backup", + }, + }, + }, + }) +} + func TestAccAWSFsxWindowsFileSystem_multiAz(t *testing.T) { var filesystem fsx.FileSystem resourceName := "aws_fsx_windows_file_system.test" @@ -148,7 +194,7 @@ func TestAccAWSFsxWindowsFileSystem_multiAz(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "subnet_ids.#", "2"), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttr(resourceName, "throughput_capacity", "8"), - resource.TestMatchResourceAttr(resourceName, "vpc_id", regexp.MustCompile(`^vpc-.+`)), + resource.TestCheckResourceAttrPair(resourceName, "vpc_id", "aws_vpc.test", "id"), resource.TestMatchResourceAttr(resourceName, "weekly_maintenance_start_time", regexp.MustCompile(`^\d:\d\d:\d\d$`)), resource.TestCheckResourceAttr(resourceName, "deployment_type", "MULTI_AZ_1"), ), @@ -937,17 +983,17 @@ resource "aws_fsx_windows_file_system" "test" { `) } -func testAccAwsFsxWindowsFileSystemConfigSubnetIds1WithSingleType() string { +func testAccAwsFsxWindowsFileSystemConfigSubnetIds1WithSingleType(azType string) string { return testAccAwsFsxWindowsFileSystemConfigBase() + fmt.Sprintf(` resource "aws_fsx_windows_file_system" "test" { active_directory_id = "${aws_directory_service_directory.test.id}" skip_final_backup = true storage_capacity = 32 - deployment_type = "SINGLE_AZ_1" + deployment_type = %[1]q subnet_ids = ["${aws_subnet.test1.id}"] throughput_capacity = 8 } -`) +`, azType) } func testAccAwsFsxWindowsFileSystemConfigSubnetIds2() string { From c29c0354bcb1b38bd8ba77d895508ee26ba02d7f Mon Sep 17 00:00:00 2001 From: Ilia Lazebnik Date: Tue, 21 Jul 2020 19:00:55 +0300 Subject: [PATCH 11/13] Update website/docs/r/fsx_windows_file_system.html.markdown Co-authored-by: Simon Davis --- website/docs/r/fsx_windows_file_system.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/fsx_windows_file_system.html.markdown b/website/docs/r/fsx_windows_file_system.html.markdown index 8a46472e131..0b9237cc391 100644 --- a/website/docs/r/fsx_windows_file_system.html.markdown +++ b/website/docs/r/fsx_windows_file_system.html.markdown @@ -89,7 +89,7 @@ In addition to all arguments above, the following attributes are exported: * `network_interface_ids` - Set of Elastic Network Interface identifiers from which the file system is accessible. * `owner_id` - AWS account identifier that created the file system. * `vpc_id` - Identifier of the Virtual Private Cloud for the file system. -* `preferred_file_server_ip` - the IP address of the primary, or preferred, file server. +* `preferred_file_server_ip` - The IP address of the primary, or preferred, file server. * `remote_administration_endpoint` - For `MULTI_AZ_1` deployment types, use this endpoint when performing administrative tasks on the file system using Amazon FSx Remote PowerShell. For `SINGLE_AZ_1` deployment types, this is the DNS name of the file system. ## Timeouts From 96a5bd2e2df68d1b2c4a80317763338ddc0166f7 Mon Sep 17 00:00:00 2001 From: Ilia Lazebnik Date: Tue, 21 Jul 2020 19:01:04 +0300 Subject: [PATCH 12/13] Update website/docs/r/fsx_windows_file_system.html.markdown Co-authored-by: Simon Davis --- website/docs/r/fsx_windows_file_system.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/fsx_windows_file_system.html.markdown b/website/docs/r/fsx_windows_file_system.html.markdown index 0b9237cc391..855f0dd51d5 100644 --- a/website/docs/r/fsx_windows_file_system.html.markdown +++ b/website/docs/r/fsx_windows_file_system.html.markdown @@ -65,7 +65,7 @@ The following arguments are supported: * `skip_final_backup` - (Optional) When enabled, will skip the default final backup taken when the file system is deleted. This configuration must be applied separately before attempting to delete the resource to have the desired behavior. Defaults to `false`. * `tags` - (Optional) A map of tags to assign to the file system. * `weekly_maintenance_start_time` - (Optional) The preferred start time (in `d:HH:MM` format) to perform weekly maintenance, in the UTC time zone. -* `deployment_type` - (Optional) Specifies the file system deployment type, valid values are `MULTI_AZ_1` and `SINGLE_AZ_1`. Default values is `SINGLE_AZ_1`. +* `deployment_type` - (Optional) Specifies the file system deployment type, valid values are `MULTI_AZ_1` and `SINGLE_AZ_1`. Default value is `SINGLE_AZ_1`. * `preferred_subnet_id` - (Optional) Specifies the subnet in which you want the preferred file server to be located. Required for when deployment type is `MULTI_AZ_1`. ### self_managed_active_directory From ca6a6340f6193e7a305c67ab195b1b6be1e692d7 Mon Sep 17 00:00:00 2001 From: Ilia Lazebnik Date: Tue, 21 Jul 2020 19:01:13 +0300 Subject: [PATCH 13/13] Update website/docs/r/fsx_windows_file_system.html.markdown Co-authored-by: Simon Davis --- website/docs/r/fsx_windows_file_system.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/fsx_windows_file_system.html.markdown b/website/docs/r/fsx_windows_file_system.html.markdown index 855f0dd51d5..5118d736a69 100644 --- a/website/docs/r/fsx_windows_file_system.html.markdown +++ b/website/docs/r/fsx_windows_file_system.html.markdown @@ -53,7 +53,7 @@ resource "aws_fsx_windows_file_system" "example" { The following arguments are supported: * `storage_capacity` - (Required) Storage capacity (GiB) of the file system. Minimum of 32 and maximum of 65536. -* `subnet_ids` - (Required) A list of IDs for the subnets that the file system will be accessible from. to specify more than a single subnet set `deployment_type` to `MULTI_AZ_1`. +* `subnet_ids` - (Required) A list of IDs for the subnets that the file system will be accessible from. To specify more than a single subnet set `deployment_type` to `MULTI_AZ_1`. * `throughput_capacity` - (Required) Throughput (megabytes per second) of the file system in power of 2 increments. Minimum of `8` and maximum of `2048`. * `active_directory_id` - (Optional) The ID for an existing Microsoft Active Directory instance that the file system should join when it's created. Cannot be specified with `self_managed_active_directory`. * `automatic_backup_retention_days` - (Optional) The number of days to retain automatic backups. Minimum of `0` and maximum of `35`. Defaults to `7`. Set to `0` to disable.