From 9c578d370e6756791b136fface2bf6b5fd6fd6ee Mon Sep 17 00:00:00 2001 From: Matthew Tse <66440247+mtpdt@users.noreply.github.com> Date: Mon, 21 Sep 2020 22:52:09 -0400 Subject: [PATCH 1/7] Add copy_tags_to_backups to aws_fsx_lustre_file_system --- aws/resource_aws_fsx_lustre_file_system.go | 11 ++++++ ...esource_aws_fsx_lustre_file_system_test.go | 37 +++++++++++++++++++ .../r/fsx_lustre_file_system.html.markdown | 4 ++ 3 files changed, 52 insertions(+) diff --git a/aws/resource_aws_fsx_lustre_file_system.go b/aws/resource_aws_fsx_lustre_file_system.go index 3adcd3dc0655..0b5f42419d07 100644 --- a/aws/resource_aws_fsx_lustre_file_system.go +++ b/aws/resource_aws_fsx_lustre_file_system.go @@ -175,6 +175,12 @@ func resourceAwsFsxLustreFileSystem() *schema.Resource { Computed: true, ValidateFunc: validation.StringInSlice(fsx.AutoImportPolicyType_Values(), false), }, + "copy_tags_to_backups": { + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + Default: false, + }, }, } } @@ -242,6 +248,10 @@ func resourceAwsFsxLustreFileSystemCreate(d *schema.ResourceData, meta interface input.LustreConfiguration.AutoImportPolicy = aws.String(v.(string)) } + if v, ok := d.GetOk("copy_tags_to_backups"); ok { + input.LustreConfiguration.CopyTagsToBackups = aws.Bool(v.(bool)) + } + result, err := conn.CreateFileSystem(input) if err != nil { return fmt.Errorf("Error creating FSx Lustre filesystem: %w", err) @@ -388,6 +398,7 @@ func resourceAwsFsxLustreFileSystemRead(d *schema.ResourceData, meta interface{} 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) + d.Set("copy_tags_to_backups", filesystem.LustreConfiguration.CopyTagsToBackups) return nil } diff --git a/aws/resource_aws_fsx_lustre_file_system_test.go b/aws/resource_aws_fsx_lustre_file_system_test.go index 6e9f6c3000fa..236ac8022737 100644 --- a/aws/resource_aws_fsx_lustre_file_system_test.go +++ b/aws/resource_aws_fsx_lustre_file_system_test.go @@ -98,6 +98,7 @@ func TestAccAWSFsxLustreFileSystem_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "deployment_type", fsx.LustreDeploymentTypeScratch1), resource.TestCheckResourceAttr(resourceName, "automatic_backup_retention_days", "0"), resource.TestCheckResourceAttr(resourceName, "storage_type", fsx.StorageTypeSsd), + resource.TestCheckResourceAttr(resourceName, "copy_tags_to_backups", false), ), }, { @@ -619,6 +620,32 @@ func TestAccAWSFsxLustreFileSystem_StorageTypeHddDriveCacheNone(t *testing.T) { }) } +func TestAccAWSFsxLustreFileSystem_CopyTagsToBackupst *testing.T) { + var filesystem fsx.FileSystem + resourceName := "aws_fsx_lustre_file_system.test" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckFsxLustreFileSystemDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAwsFsxLustreFileSystemCopyTagsToBackups(), + Check: resource.ComposeTestCheckFunc( + testAccCheckFsxLustreFileSystemExists(resourceName, &filesystem), + resource.TestCheckResourceAttr(resourceName, "copy_tags_to_backups", true), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"security_group_ids"}, + }, + }, + }) +} + func TestAccAWSFsxLustreFileSystem_autoImportPolicy(t *testing.T) { var filesystem fsx.FileSystem resourceName := "aws_fsx_lustre_file_system.test" @@ -1034,3 +1061,13 @@ resource "aws_fsx_lustre_file_system" "test" { } `, rName, exportPrefix, policy) } + +func testAccAwsFsxLustreFileSystemCopyTagsToBackups() string { + return testAccAwsFsxLustreFileSystemConfigBase() + ` +resource "aws_fsx_lustre_file_system" "test" { + storage_capacity = 1200 + subnet_ids = [aws_subnet.test1.id] + copy_tags_to_backups = true +} +` +} diff --git a/website/docs/r/fsx_lustre_file_system.html.markdown b/website/docs/r/fsx_lustre_file_system.html.markdown index 754d26a5a32e..f491cdcc0cb9 100644 --- a/website/docs/r/fsx_lustre_file_system.html.markdown +++ b/website/docs/r/fsx_lustre_file_system.html.markdown @@ -36,10 +36,14 @@ The following arguments are supported: * `kms_key_id` - (Optional) ARN for the KMS Key to encrypt the file system at rest, applicable for `PERSISTENT_1`. Defaults to an AWS managed KMS Key. * `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. Valid values for `SSD` storage_type are 50, 100, 200. Valid values for `HDD` storage_type are 12, 40. * `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. +<<<<<<< HEAD * `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. * `auto_import_policy` - (Optional) How Amazon FSx keeps your file and directory listings up to date as you add or modify objects in your linked S3 bucket. see [Auto Import Data Repo](https://docs.aws.amazon.com/fsx/latest/LustreGuide/autoimport-data-repo.html) for more details. +======= +* `copy_tags_to_backups` - (Optional) A boolean flag indicating whether tags for the file system should be copied to backups. The default value is false. +>>>>>>> 2c72e0244... Add copy_tags_to_backups to aws_fsx_lustre_file_system ## Attributes Reference From 67d06996be0c9a06a5dac4d568fc7174b3f3e679 Mon Sep 17 00:00:00 2001 From: drfaust92 Date: Fri, 16 Oct 2020 21:30:03 +0300 Subject: [PATCH 2/7] fix --- aws/resource_aws_fsx_lustre_file_system_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws/resource_aws_fsx_lustre_file_system_test.go b/aws/resource_aws_fsx_lustre_file_system_test.go index 236ac8022737..157bf860271f 100644 --- a/aws/resource_aws_fsx_lustre_file_system_test.go +++ b/aws/resource_aws_fsx_lustre_file_system_test.go @@ -620,7 +620,7 @@ func TestAccAWSFsxLustreFileSystem_StorageTypeHddDriveCacheNone(t *testing.T) { }) } -func TestAccAWSFsxLustreFileSystem_CopyTagsToBackupst *testing.T) { +func TestAccAWSFsxLustreFileSystemCopyTagsToBackups(t *testing.T) { var filesystem fsx.FileSystem resourceName := "aws_fsx_lustre_file_system.test" From 6dbc238541483223d23201f9c4b8b329e1c2669e Mon Sep 17 00:00:00 2001 From: drfaust92 Date: Fri, 16 Oct 2020 21:33:29 +0300 Subject: [PATCH 3/7] fix test --- aws/resource_aws_fsx_lustre_file_system_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aws/resource_aws_fsx_lustre_file_system_test.go b/aws/resource_aws_fsx_lustre_file_system_test.go index 157bf860271f..e9c60d081039 100644 --- a/aws/resource_aws_fsx_lustre_file_system_test.go +++ b/aws/resource_aws_fsx_lustre_file_system_test.go @@ -98,7 +98,7 @@ func TestAccAWSFsxLustreFileSystem_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "deployment_type", fsx.LustreDeploymentTypeScratch1), resource.TestCheckResourceAttr(resourceName, "automatic_backup_retention_days", "0"), resource.TestCheckResourceAttr(resourceName, "storage_type", fsx.StorageTypeSsd), - resource.TestCheckResourceAttr(resourceName, "copy_tags_to_backups", false), + resource.TestCheckResourceAttr(resourceName, "copy_tags_to_backups", "false"), ), }, { @@ -633,7 +633,7 @@ func TestAccAWSFsxLustreFileSystemCopyTagsToBackups(t *testing.T) { Config: testAccAwsFsxLustreFileSystemCopyTagsToBackups(), Check: resource.ComposeTestCheckFunc( testAccCheckFsxLustreFileSystemExists(resourceName, &filesystem), - resource.TestCheckResourceAttr(resourceName, "copy_tags_to_backups", true), + resource.TestCheckResourceAttr(resourceName, "copy_tags_to_backups", "true"), ), }, { From c115a4f353756f7bfd88da225d5238c10933ad69 Mon Sep 17 00:00:00 2001 From: drfaust92 Date: Sat, 17 Oct 2020 00:24:45 +0300 Subject: [PATCH 4/7] fmt --- aws/resource_aws_fsx_lustre_file_system_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_fsx_lustre_file_system_test.go b/aws/resource_aws_fsx_lustre_file_system_test.go index e9c60d081039..577dd0006cbd 100644 --- a/aws/resource_aws_fsx_lustre_file_system_test.go +++ b/aws/resource_aws_fsx_lustre_file_system_test.go @@ -1065,9 +1065,9 @@ resource "aws_fsx_lustre_file_system" "test" { func testAccAwsFsxLustreFileSystemCopyTagsToBackups() string { return testAccAwsFsxLustreFileSystemConfigBase() + ` resource "aws_fsx_lustre_file_system" "test" { - storage_capacity = 1200 - subnet_ids = [aws_subnet.test1.id] - copy_tags_to_backups = true + storage_capacity = 1200 + subnet_ids = [aws_subnet.test1.id] + copy_tags_to_backups = true } ` } From 02ed165a4d001a1c023f31cc3fa827b650ae9c36 Mon Sep 17 00:00:00 2001 From: drfaust92 Date: Sat, 17 Oct 2020 00:42:26 +0300 Subject: [PATCH 5/7] redme --- website/docs/r/fsx_lustre_file_system.html.markdown | 3 --- 1 file changed, 3 deletions(-) diff --git a/website/docs/r/fsx_lustre_file_system.html.markdown b/website/docs/r/fsx_lustre_file_system.html.markdown index f491cdcc0cb9..2a234782f327 100644 --- a/website/docs/r/fsx_lustre_file_system.html.markdown +++ b/website/docs/r/fsx_lustre_file_system.html.markdown @@ -36,14 +36,11 @@ The following arguments are supported: * `kms_key_id` - (Optional) ARN for the KMS Key to encrypt the file system at rest, applicable for `PERSISTENT_1`. Defaults to an AWS managed KMS Key. * `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. Valid values for `SSD` storage_type are 50, 100, 200. Valid values for `HDD` storage_type are 12, 40. * `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. -<<<<<<< HEAD * `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. * `auto_import_policy` - (Optional) How Amazon FSx keeps your file and directory listings up to date as you add or modify objects in your linked S3 bucket. see [Auto Import Data Repo](https://docs.aws.amazon.com/fsx/latest/LustreGuide/autoimport-data-repo.html) for more details. -======= * `copy_tags_to_backups` - (Optional) A boolean flag indicating whether tags for the file system should be copied to backups. The default value is false. ->>>>>>> 2c72e0244... Add copy_tags_to_backups to aws_fsx_lustre_file_system ## Attributes Reference From 92ce38d69899d41141ead97ae74d26bc36b0e8fa Mon Sep 17 00:00:00 2001 From: drfaust92 Date: Sat, 17 Oct 2020 00:47:13 +0300 Subject: [PATCH 6/7] fix test name --- aws/resource_aws_fsx_lustre_file_system_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws/resource_aws_fsx_lustre_file_system_test.go b/aws/resource_aws_fsx_lustre_file_system_test.go index 577dd0006cbd..9451725ab73c 100644 --- a/aws/resource_aws_fsx_lustre_file_system_test.go +++ b/aws/resource_aws_fsx_lustre_file_system_test.go @@ -620,7 +620,7 @@ func TestAccAWSFsxLustreFileSystem_StorageTypeHddDriveCacheNone(t *testing.T) { }) } -func TestAccAWSFsxLustreFileSystemCopyTagsToBackups(t *testing.T) { +func TestAccAWSFsxLustreFileSystem_copyTagsToBackups(t *testing.T) { var filesystem fsx.FileSystem resourceName := "aws_fsx_lustre_file_system.test" From 5f0337cba43cde0e4f183332d78be56d547fd3f4 Mon Sep 17 00:00:00 2001 From: drfaust92 Date: Sat, 17 Oct 2020 00:55:06 +0300 Subject: [PATCH 7/7] add persistent type for copy tags to backups --- aws/resource_aws_fsx_lustre_file_system_test.go | 8 +++++--- website/docs/r/fsx_lustre_file_system.html.markdown | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/aws/resource_aws_fsx_lustre_file_system_test.go b/aws/resource_aws_fsx_lustre_file_system_test.go index 9451725ab73c..583344d1d039 100644 --- a/aws/resource_aws_fsx_lustre_file_system_test.go +++ b/aws/resource_aws_fsx_lustre_file_system_test.go @@ -1065,9 +1065,11 @@ resource "aws_fsx_lustre_file_system" "test" { func testAccAwsFsxLustreFileSystemCopyTagsToBackups() string { return testAccAwsFsxLustreFileSystemConfigBase() + ` resource "aws_fsx_lustre_file_system" "test" { - storage_capacity = 1200 - subnet_ids = [aws_subnet.test1.id] - copy_tags_to_backups = true + storage_capacity = 1200 + deployment_type = "PERSISTENT_1" + subnet_ids = [aws_subnet.test1.id] + per_unit_storage_throughput = 50 + copy_tags_to_backups = true } ` } diff --git a/website/docs/r/fsx_lustre_file_system.html.markdown b/website/docs/r/fsx_lustre_file_system.html.markdown index 2a234782f327..2aa9578196a9 100644 --- a/website/docs/r/fsx_lustre_file_system.html.markdown +++ b/website/docs/r/fsx_lustre_file_system.html.markdown @@ -33,14 +33,14 @@ 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) - The filesystem deployment type. One of: `SCRATCH_1`, `SCRATCH_2`, `PERSISTENT_1`. -* `kms_key_id` - (Optional) ARN for the KMS Key to encrypt the file system at rest, applicable for `PERSISTENT_1`. Defaults to an AWS managed KMS Key. +* `kms_key_id` - (Optional) ARN for the KMS Key to encrypt the file system at rest, applicable for `PERSISTENT_1` deployment_type. Defaults to an AWS managed KMS Key. * `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. Valid values for `SSD` storage_type are 50, 100, 200. Valid values for `HDD` storage_type are 12, 40. * `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. * `auto_import_policy` - (Optional) How Amazon FSx keeps your file and directory listings up to date as you add or modify objects in your linked S3 bucket. see [Auto Import Data Repo](https://docs.aws.amazon.com/fsx/latest/LustreGuide/autoimport-data-repo.html) for more details. -* `copy_tags_to_backups` - (Optional) A boolean flag indicating whether tags for the file system should be copied to backups. The default value is false. +* `copy_tags_to_backups` - (Optional) A boolean flag indicating whether tags for the file system should be copied to backups. Applicable for `PERSISTENT_1` deployment_type. The default value is false. ## Attributes Reference