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

fsx_lustre_file_system - support daily_automatic_backup_start_time #15299

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
19 changes: 19 additions & 0 deletions aws/resource_aws_fsx_lustre_file_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,15 @@ func resourceAwsFsxLustreFileSystem() *schema.Resource {
Computed: true,
ValidateFunc: validation.IntBetween(0, 35),
},
"daily_automatic_backup_start_time": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.All(
validation.StringLenBetween(5, 5),
validation.StringMatch(regexp.MustCompile(`^([01]\d|2[0-3]):?([0-5]\d)$`), "must be in the format HH:MM"),
),
},
"storage_type": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -190,6 +199,10 @@ func resourceAwsFsxLustreFileSystemCreate(d *schema.ResourceData, meta interface
input.LustreConfiguration.AutomaticBackupRetentionDays = aws.Int64(int64(v.(int)))
}

if v, ok := d.GetOk("daily_automatic_backup_start_time"); ok {
input.LustreConfiguration.DailyAutomaticBackupStartTime = aws.String(v.(string))
}

if v, ok := d.GetOk("export_path"); ok {
input.LustreConfiguration.ExportPath = aws.String(v.(string))
}
Expand Down Expand Up @@ -266,6 +279,11 @@ func resourceAwsFsxLustreFileSystemUpdate(d *schema.ResourceData, meta interface
requestUpdate = true
}

if d.HasChange("daily_automatic_backup_start_time") {
input.LustreConfiguration.DailyAutomaticBackupStartTime = aws.String(d.Get("daily_automatic_backup_start_time").(string))
requestUpdate = true
}

if requestUpdate {
_, err := conn.UpdateFileSystem(input)
if err != nil {
Expand Down Expand Up @@ -356,6 +374,7 @@ func resourceAwsFsxLustreFileSystemRead(d *schema.ResourceData, meta interface{}
d.Set("vpc_id", filesystem.VpcId)
d.Set("weekly_maintenance_start_time", lustreConfig.WeeklyMaintenanceStartTime)
d.Set("automatic_backup_retention_days", lustreConfig.AutomaticBackupRetentionDays)
d.Set("daily_automatic_backup_start_time", lustreConfig.DailyAutomaticBackupStartTime)

return nil
}
Expand Down
51 changes: 49 additions & 2 deletions aws/resource_aws_fsx_lustre_file_system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,40 @@ func TestAccAWSFsxLustreFileSystem_automaticBackupRetentionDays(t *testing.T) {
})
}

func TestAccAWSFsxLustreFileSystem_dailyAutomaticBackupStartTime(t *testing.T) {
var filesystem1, filesystem2 fsx.FileSystem
resourceName := "aws_fsx_lustre_file_system.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck("fsx", t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckFsxLustreFileSystemDestroy,
Steps: []resource.TestStep{
{
Config: testAccAwsFsxLustreFileSystemConfigDailyAutomaticBackupStartTime("01:01"),
Check: resource.ComposeTestCheckFunc(
testAccCheckFsxLustreFileSystemExists(resourceName, &filesystem1),
resource.TestCheckResourceAttr(resourceName, "daily_automatic_backup_start_time", "01:01"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"security_group_ids"},
},
{
Config: testAccAwsFsxLustreFileSystemConfigDailyAutomaticBackupStartTime("02:02"),
Check: resource.ComposeTestCheckFunc(
testAccCheckFsxLustreFileSystemExists(resourceName, &filesystem2),
testAccCheckFsxLustreFileSystemNotRecreated(&filesystem1, &filesystem2),
resource.TestCheckResourceAttr(resourceName, "daily_automatic_backup_start_time", "02:02"),
),
},
},
})
}

func TestAccAWSFsxLustreFileSystem_DeploymentTypePersistent1(t *testing.T) {
var filesystem fsx.FileSystem
resourceName := "aws_fsx_lustre_file_system.test"
Expand Down Expand Up @@ -534,7 +568,7 @@ func TestAccAWSFsxLustreFileSystem_StorageTypeHddDriveCacheRead(t *testing.T) {
resourceName := "aws_fsx_lustre_file_system.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck("fsx", t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckFsxLustreFileSystemDestroy,
Steps: []resource.TestStep{
Expand All @@ -561,7 +595,7 @@ func TestAccAWSFsxLustreFileSystem_StorageTypeHddDriveCacheNone(t *testing.T) {
resourceName := "aws_fsx_lustre_file_system.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck("fsx", t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckFsxLustreFileSystemDestroy,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -855,6 +889,19 @@ resource "aws_fsx_lustre_file_system" "test" {
`, weeklyMaintenanceStartTime)
}

func testAccAwsFsxLustreFileSystemConfigDailyAutomaticBackupStartTime(dailyAutomaticBackupStartTime string) string {
return testAccAwsFsxLustreFileSystemConfigBase() + fmt.Sprintf(`
resource "aws_fsx_lustre_file_system" "test" {
storage_capacity = 1200
subnet_ids = [aws_subnet.test1.id]
deployment_type = "PERSISTENT_1"
per_unit_storage_throughput = 50
daily_automatic_backup_start_time = %[1]q
automatic_backup_retention_days = 1
}
`, dailyAutomaticBackupStartTime)
}

func testAccAwsFsxLustreFileSystemConfigAutomaticBackupRetentionDays(retention int) string {
return testAccAwsFsxLustreFileSystemConfigBase() + fmt.Sprintf(`
resource "aws_fsx_lustre_file_system" "test" {
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/fsx_lustre_file_system.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ The following arguments are supported:
* `automatic_backup_retention_days` - (Optional) The number of days to retain automatic backups. Setting this to 0 disables automatic backups. You can retain automatic backups for a maximum of 35 days. only valid for `PERSISTENT_1` deployment_type.
* `storage_type` - (Optional) - The filesystem storage type. Either `SSD` or `HDD`, defaults to `SSD`. `HDD` is only supported on `PERSISTENT_1` deployment types.
* `drive_cache_type` - (Optional) - The type of drive cache used by `PERSISTENT_1` filesystems that are provisioned with `HDD` storage_type. Required for `HDD` storage_type, set to either `READ` or `NONE`.
* `daily_automatic_backup_start_time` - (Optional) A recurring daily time, in the format HH:MM. HH is the zero-padded hour of the day (0-23), and MM is the zero-padded minute of the hour. For example, 05:00 specifies 5 AM daily. only valid for `PERSISTENT_1` deployment_type. Requires `automatic_backup_retention_days` to be set.

## Attributes Reference

Expand Down