From 4550e0c70bd88a9fbf0239ef8bbfc9f2f7baad58 Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Wed, 22 Jul 2020 23:22:46 +0300 Subject: [PATCH 1/3] add support for storage type --- aws/resource_aws_fsx_windows_file_system.go | 15 ++++++ ...source_aws_fsx_windows_file_system_test.go | 47 +++++++++++++++++++ .../r/fsx_windows_file_system.html.markdown | 1 + 3 files changed, 63 insertions(+) diff --git a/aws/resource_aws_fsx_windows_file_system.go b/aws/resource_aws_fsx_windows_file_system.go index a45d7308d64e..081b5675a6e6 100644 --- a/aws/resource_aws_fsx_windows_file_system.go +++ b/aws/resource_aws_fsx_windows_file_system.go @@ -201,6 +201,16 @@ func resourceAwsFsxWindowsFileSystem() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "storage_type": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Default: fsx.StorageTypeSsd, + ValidateFunc: validation.StringInSlice([]string{ + fsx.StorageTypeSsd, + fsx.StorageTypeHdd, + }, false), + }, }, } } @@ -256,6 +266,10 @@ func resourceAwsFsxWindowsFileSystemCreate(d *schema.ResourceData, meta interfac input.WindowsConfiguration.WeeklyMaintenanceStartTime = aws.String(v.(string)) } + if v, ok := d.GetOk("storage_type"); ok { + input.StorageType = aws.String(v.(string)) + } + result, err := conn.CreateFileSystem(input) if err != nil { return fmt.Errorf("Error creating FSx filesystem: %s", err) @@ -361,6 +375,7 @@ func resourceAwsFsxWindowsFileSystemRead(d *schema.ResourceData, meta interface{ d.Set("remote_administration_endpoint", filesystem.WindowsConfiguration.RemoteAdministrationEndpoint) d.Set("dns_name", filesystem.DNSName) d.Set("kms_key_id", filesystem.KmsKeyId) + d.Set("storage_type", filesystem.StorageType) if err := d.Set("network_interface_ids", aws.StringValueSlice(filesystem.NetworkInterfaceIds)); err != nil { return fmt.Errorf("error setting network_interface_ids: %s", err) diff --git a/aws/resource_aws_fsx_windows_file_system_test.go b/aws/resource_aws_fsx_windows_file_system_test.go index 1d0277569401..1f860903b57b 100644 --- a/aws/resource_aws_fsx_windows_file_system_test.go +++ b/aws/resource_aws_fsx_windows_file_system_test.go @@ -102,6 +102,7 @@ func TestAccAWSFsxWindowsFileSystem_basic(t *testing.T) { 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"), + resource.TestCheckResourceAttr(resourceName, "storage_type", "SSD"), ), }, { @@ -152,6 +153,37 @@ func TestAccAWSFsxWindowsFileSystem_singleAz2(t *testing.T) { 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"), + resource.TestCheckResourceAttr(resourceName, "storage_type", "SSD"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "security_group_ids", + "skip_final_backup", + }, + }, + }, + }) +} + +func TestAccAWSFsxWindowsFileSystem_storageTypeHdd(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: testAccAwsFsxWindowsFileSystemConfigSubnetIds1WithSingleTypeWithStorage("SINGLE_AZ_2", "HDD"), + Check: resource.ComposeTestCheckFunc( + testAccCheckFsxWindowsFileSystemExists(resourceName, &filesystem), + resource.TestCheckResourceAttr(resourceName, "deployment_type", "SINGLE_AZ_2"), + resource.TestCheckResourceAttr(resourceName, "storage_type", "HDD"), ), }, { @@ -197,6 +229,7 @@ func TestAccAWSFsxWindowsFileSystem_multiAz(t *testing.T) { 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"), + resource.TestCheckResourceAttr(resourceName, "storage_type", "SSD"), ), }, { @@ -996,6 +1029,20 @@ resource "aws_fsx_windows_file_system" "test" { `, azType) } +func testAccAwsFsxWindowsFileSystemConfigSubnetIds1WithSingleTypeWithStorage(azType, storageType 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 = %[1]q + subnet_ids = ["${aws_subnet.test1.id}"] + throughput_capacity = 8 + storage_type = %[2]q +} +`, azType, storageType) +} + func testAccAwsFsxWindowsFileSystemConfigSubnetIds2() string { return testAccAwsFsxWindowsFileSystemConfigBase() + fmt.Sprintf(` resource "aws_fsx_windows_file_system" "test" { diff --git a/website/docs/r/fsx_windows_file_system.html.markdown b/website/docs/r/fsx_windows_file_system.html.markdown index 5118d736a691..e88c494b0e37 100644 --- a/website/docs/r/fsx_windows_file_system.html.markdown +++ b/website/docs/r/fsx_windows_file_system.html.markdown @@ -67,6 +67,7 @@ The following arguments are supported: * `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 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`. +* `storage_type` - (Optional) Specifies the storage type, Valid values are `SSD` and `HDD`. `HDD` is supported on `SINGLE_AZ_1` and `MULTI_AZ_1` Windows file system deployment types. Default value is `SSD`. ### self_managed_active_directory From 95e025195054ea5aebff436e77caee2773d9f3d8 Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Thu, 23 Jul 2020 09:58:39 +0300 Subject: [PATCH 2/3] storage capacity for hdd needs to be at least 2000 --- aws/resource_aws_fsx_windows_file_system_test.go | 6 +++--- 1 file changed, 3 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 1f860903b57b..184f8f82712b 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_storageTypeHdd(t *testing.T) { CheckDestroy: testAccCheckFsxWindowsFileSystemDestroy, Steps: []resource.TestStep{ { - Config: testAccAwsFsxWindowsFileSystemConfigSubnetIds1WithSingleTypeWithStorage("SINGLE_AZ_2", "HDD"), + Config: testAccAwsFsxWindowsFileSystemConfigSubnetIds1WithStorageType("SINGLE_AZ_2", "HDD"), Check: resource.ComposeTestCheckFunc( testAccCheckFsxWindowsFileSystemExists(resourceName, &filesystem), resource.TestCheckResourceAttr(resourceName, "deployment_type", "SINGLE_AZ_2"), @@ -1029,12 +1029,12 @@ resource "aws_fsx_windows_file_system" "test" { `, azType) } -func testAccAwsFsxWindowsFileSystemConfigSubnetIds1WithSingleTypeWithStorage(azType, storageType string) string { +func testAccAwsFsxWindowsFileSystemConfigSubnetIds1WithStorageType(azType, storageType 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 + storage_capacity = 2000 deployment_type = %[1]q subnet_ids = ["${aws_subnet.test1.id}"] throughput_capacity = 8 From 1b6233f39b2752f43e9edaf9ed89536626a62df2 Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Thu, 23 Jul 2020 10:25:27 +0300 Subject: [PATCH 3/3] storage capacity for hdd needs to be at least 2000 --- 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 e88c494b0e37..8d0f420b044f 100644 --- a/website/docs/r/fsx_windows_file_system.html.markdown +++ b/website/docs/r/fsx_windows_file_system.html.markdown @@ -52,7 +52,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. +* `storage_capacity` - (Required) Storage capacity (GiB) of the file system. Minimum of 32 and maximum of 65536. If the storage type is set to `HDD` the minimum value is 2000. * `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`.