Skip to content

Commit 47d4803

Browse files
Merge pull request #13639 from pdtpartners/f-aws_fsx_lustre_file_system-deployment_type
Add deployment type to aws_fsx_lustre_file_system
2 parents 55cf291 + 4ba8382 commit 47d4803

3 files changed

Lines changed: 123 additions & 0 deletions

File tree

aws/resource_aws_fsx_lustre_file_system.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,27 @@ func resourceAwsFsxLustreFileSystem() *schema.Resource {
108108
validation.StringMatch(regexp.MustCompile(`^[1-7]:([01]\d|2[0-3]):?([0-5]\d)$`), "must be in the format d:HH:MM"),
109109
),
110110
},
111+
"deployment_type": {
112+
Type: schema.TypeString,
113+
Optional: true,
114+
ForceNew: true,
115+
Default: fsx.LustreDeploymentTypeScratch1,
116+
ValidateFunc: validation.StringInSlice([]string{
117+
fsx.LustreDeploymentTypeScratch1,
118+
fsx.LustreDeploymentTypeScratch2,
119+
fsx.LustreDeploymentTypePersistent1,
120+
}, false),
121+
},
122+
"per_unit_storage_throughput": {
123+
Type: schema.TypeInt,
124+
Optional: true,
125+
ForceNew: true,
126+
ValidateFunc: validation.IntInSlice([]int{
127+
50,
128+
100,
129+
200,
130+
}),
131+
},
111132
},
112133
}
113134
}
@@ -162,6 +183,22 @@ func resourceAwsFsxLustreFileSystemCreate(d *schema.ResourceData, meta interface
162183
input.LustreConfiguration.WeeklyMaintenanceStartTime = aws.String(v.(string))
163184
}
164185

186+
if v, ok := d.GetOk("deployment_type"); ok {
187+
if input.LustreConfiguration == nil {
188+
input.LustreConfiguration = &fsx.CreateFileSystemLustreConfiguration{}
189+
}
190+
191+
input.LustreConfiguration.DeploymentType = aws.String(v.(string))
192+
}
193+
194+
if v, ok := d.GetOk("per_unit_storage_throughput"); ok {
195+
if input.LustreConfiguration == nil {
196+
input.LustreConfiguration = &fsx.CreateFileSystemLustreConfiguration{}
197+
}
198+
199+
input.LustreConfiguration.PerUnitStorageThroughput = aws.Int64(int64(v.(int)))
200+
}
201+
165202
result, err := conn.CreateFileSystem(input)
166203
if err != nil {
167204
return fmt.Errorf("Error creating FSx filesystem: %s", err)
@@ -251,6 +288,10 @@ func resourceAwsFsxLustreFileSystemRead(d *schema.ResourceData, meta interface{}
251288
d.Set("export_path", filesystem.LustreConfiguration.DataRepositoryConfiguration.ExportPath)
252289
d.Set("import_path", filesystem.LustreConfiguration.DataRepositoryConfiguration.ImportPath)
253290
d.Set("imported_file_chunk_size", filesystem.LustreConfiguration.DataRepositoryConfiguration.ImportedFileChunkSize)
291+
d.Set("deployment_type", filesystem.LustreConfiguration.DeploymentType)
292+
if filesystem.LustreConfiguration.PerUnitStorageThroughput != nil {
293+
d.Set("per_unit_storage_throughput", filesystem.LustreConfiguration.PerUnitStorageThroughput)
294+
}
254295

255296
if err := d.Set("network_interface_ids", aws.StringValueSlice(filesystem.NetworkInterfaceIds)); err != nil {
256297
return fmt.Errorf("error setting network_interface_ids: %s", err)

aws/resource_aws_fsx_lustre_file_system_test.go

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ func TestAccAWSFsxLustreFileSystem_basic(t *testing.T) {
9494
resource.TestCheckResourceAttr(resourceName, "tags.%", "0"),
9595
resource.TestMatchResourceAttr(resourceName, "vpc_id", regexp.MustCompile(`^vpc-.+`)),
9696
resource.TestMatchResourceAttr(resourceName, "weekly_maintenance_start_time", regexp.MustCompile(`^\d:\d\d:\d\d$`)),
97+
resource.TestCheckResourceAttr(resourceName, "deployment_type", fsx.LustreDeploymentTypeScratch1),
9798
),
9899
},
99100
{
@@ -102,6 +103,10 @@ func TestAccAWSFsxLustreFileSystem_basic(t *testing.T) {
102103
ImportStateVerify: true,
103104
ImportStateVerifyIgnore: []string{"security_group_ids"},
104105
},
106+
{
107+
Config: testAccAwsFsxLustreFileSystemDeploymentType(fsx.LustreDeploymentTypeScratch1),
108+
PlanOnly: true,
109+
},
105110
},
106111
})
107112
}
@@ -382,6 +387,60 @@ func TestAccAWSFsxLustreFileSystem_WeeklyMaintenanceStartTime(t *testing.T) {
382387
})
383388
}
384389

390+
func TestAccAWSFsxLustreFileSystem_DeploymentTypePersistent1(t *testing.T) {
391+
var filesystem fsx.FileSystem
392+
resourceName := "aws_fsx_lustre_file_system.test"
393+
394+
resource.ParallelTest(t, resource.TestCase{
395+
PreCheck: func() { testAccPreCheck(t) },
396+
Providers: testAccProviders,
397+
CheckDestroy: testAccCheckFsxLustreFileSystemDestroy,
398+
Steps: []resource.TestStep{
399+
{
400+
Config: testAccAwsFsxLustreFileSystemPersistentDeploymentType(50),
401+
Check: resource.ComposeTestCheckFunc(
402+
testAccCheckFsxLustreFileSystemExists(resourceName, &filesystem),
403+
// per_unit_storage_throughput is only available with deployment_type=PERSISTENT_1, so we test both here.
404+
resource.TestCheckResourceAttr(resourceName, "per_unit_storage_throughput", "50"),
405+
resource.TestCheckResourceAttr(resourceName, "deployment_type", fsx.LustreDeploymentTypePersistent1),
406+
),
407+
},
408+
{
409+
ResourceName: resourceName,
410+
ImportState: true,
411+
ImportStateVerify: true,
412+
ImportStateVerifyIgnore: []string{"security_group_ids"},
413+
},
414+
},
415+
})
416+
}
417+
418+
func TestAccAWSFsxLustreFileSystem_DeploymentTypeScratch2(t *testing.T) {
419+
var filesystem fsx.FileSystem
420+
resourceName := "aws_fsx_lustre_file_system.test"
421+
422+
resource.ParallelTest(t, resource.TestCase{
423+
PreCheck: func() { testAccPreCheck(t) },
424+
Providers: testAccProviders,
425+
CheckDestroy: testAccCheckFsxLustreFileSystemDestroy,
426+
Steps: []resource.TestStep{
427+
{
428+
Config: testAccAwsFsxLustreFileSystemDeploymentType(fsx.LustreDeploymentTypeScratch2),
429+
Check: resource.ComposeTestCheckFunc(
430+
testAccCheckFsxLustreFileSystemExists(resourceName, &filesystem),
431+
resource.TestCheckResourceAttr(resourceName, "deployment_type", fsx.LustreDeploymentTypeScratch2),
432+
),
433+
},
434+
{
435+
ResourceName: resourceName,
436+
ImportState: true,
437+
ImportStateVerify: true,
438+
ImportStateVerifyIgnore: []string{"security_group_ids"},
439+
},
440+
},
441+
})
442+
}
443+
385444
func testAccCheckFsxLustreFileSystemExists(resourceName string, fs *fsx.FileSystem) resource.TestCheckFunc {
386445
return func(s *terraform.State) error {
387446
rs, ok := s.RootModule().Resources[resourceName]
@@ -671,3 +730,24 @@ resource "aws_fsx_lustre_file_system" "test" {
671730
}
672731
`, weeklyMaintenanceStartTime)
673732
}
733+
734+
func testAccAwsFsxLustreFileSystemDeploymentType(deploymentType string) string {
735+
return testAccAwsFsxLustreFileSystemConfigBase() + fmt.Sprintf(`
736+
resource "aws_fsx_lustre_file_system" "test" {
737+
storage_capacity = 1200
738+
subnet_ids = ["${aws_subnet.test1.id}"]
739+
deployment_type = %[1]q
740+
}
741+
`, deploymentType)
742+
}
743+
744+
func testAccAwsFsxLustreFileSystemPersistentDeploymentType(perUnitStorageThroughput int) string {
745+
return testAccAwsFsxLustreFileSystemConfigBase() + fmt.Sprintf(`
746+
resource "aws_fsx_lustre_file_system" "test" {
747+
storage_capacity = 1200
748+
subnet_ids = ["${aws_subnet.test1.id}"]
749+
deployment_type = "PERSISTENT_1"
750+
per_unit_storage_throughput = %[1]d
751+
}
752+
`, perUnitStorageThroughput)
753+
}

website/docs/r/fsx_lustre_file_system.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ The following arguments are supported:
3232
* `security_group_ids` - (Optional) A list of IDs for the security groups that apply to the specified network interfaces created for file system access. These security groups will apply to all network interfaces.
3333
* `tags` - (Optional) A map of tags to assign to the file system.
3434
* `weekly_maintenance_start_time` - (Optional) The preferred start time (in `d:HH:MM` format) to perform weekly maintenance, in the UTC time zone.
35+
* `deployment_type` - (Optional) - The filesystem deployment type. One of: `SCRATCH_1`, `SCRATCH_2`, `PERSISTENT_1`.
36+
* `per_unit_storage_throughput` - (Optional) - Describes the amount of read and write throughput for each 1 tebibyte of storage, in MB/s/TiB, required for the `PERSISTENT_1` deployment_type. For valid values, see the [AWS documentation](https://docs.aws.amazon.com/fsx/latest/APIReference/API_CreateFileSystemLustreConfiguration.html).
3537

3638
## Attributes Reference
3739

0 commit comments

Comments
 (0)