Skip to content

Commit

Permalink
Merge pull request #14316 from DrFaust92/r/fsx_windows_storage_type
Browse files Browse the repository at this point in the history
r/fsx_windows_file_system - add storage type
  • Loading branch information
breathingdust authored Jul 28, 2020
2 parents 491b3de + 1b6233f commit 614fc67
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
15 changes: 15 additions & 0 deletions aws/resource_aws_fsx_windows_file_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
},
}
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
47 changes: 47 additions & 0 deletions aws/resource_aws_fsx_windows_file_system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
{
Expand Down Expand Up @@ -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: testAccAwsFsxWindowsFileSystemConfigSubnetIds1WithStorageType("SINGLE_AZ_2", "HDD"),
Check: resource.ComposeTestCheckFunc(
testAccCheckFsxWindowsFileSystemExists(resourceName, &filesystem),
resource.TestCheckResourceAttr(resourceName, "deployment_type", "SINGLE_AZ_2"),
resource.TestCheckResourceAttr(resourceName, "storage_type", "HDD"),
),
},
{
Expand Down Expand Up @@ -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"),
),
},
{
Expand Down Expand Up @@ -996,6 +1029,20 @@ resource "aws_fsx_windows_file_system" "test" {
`, azType)
}

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 = 2000
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" {
Expand Down
3 changes: 2 additions & 1 deletion website/docs/r/fsx_windows_file_system.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -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

Expand Down

0 comments on commit 614fc67

Please sign in to comment.