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

fix: Set max # of lifecycle_policy blocks to 3 to allow setting all policies #35522

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/35522.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_efs_file_system: Increase `lifecycle_policy` maximum item limit to 3
```
2 changes: 1 addition & 1 deletion internal/service/efs/file_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func ResourceFileSystem() *schema.Resource {
"lifecycle_policy": {
Type: schema.TypeList,
Optional: true,
MaxItems: 2,
MaxItems: 3,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"transition_to_archive": {
Expand Down
43 changes: 43 additions & 0 deletions internal/service/efs/file_system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,29 @@ func TestAccEFSFileSystem_lifecyclePolicy(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "lifecycle_policy.1.transition_to_primary_storage_class", ""),
),
},
{
Config: testAccFileSystemConfig_lifecyclePolicyAll(
"transition_to_primary_storage_class",
efs.TransitionToPrimaryStorageClassRulesAfter1Access,
"transition_to_ia",
efs.TransitionToIARulesAfter30Days,
"transition_to_archive",
efs.TransitionToArchiveRulesAfter60Days,
),
Check: resource.ComposeTestCheckFunc(
testAccCheckFileSystem(ctx, resourceName, &desc),
resource.TestCheckResourceAttr(resourceName, "lifecycle_policy.#", "3"),
resource.TestCheckResourceAttr(resourceName, "lifecycle_policy.0.transition_to_archive", ""),
resource.TestCheckResourceAttr(resourceName, "lifecycle_policy.0.transition_to_ia", ""),
resource.TestCheckResourceAttr(resourceName, "lifecycle_policy.0.transition_to_primary_storage_class", efs.TransitionToPrimaryStorageClassRulesAfter1Access),
resource.TestCheckResourceAttr(resourceName, "lifecycle_policy.1.transition_to_archive", ""),
resource.TestCheckResourceAttr(resourceName, "lifecycle_policy.1.transition_to_ia", efs.TransitionToIARulesAfter30Days),
resource.TestCheckResourceAttr(resourceName, "lifecycle_policy.1.transition_to_primary_storage_class", ""),
resource.TestCheckResourceAttr(resourceName, "lifecycle_policy.2.transition_to_archive", efs.TransitionToArchiveRulesAfter60Days),
resource.TestCheckResourceAttr(resourceName, "lifecycle_policy.2.transition_to_ia", ""),
resource.TestCheckResourceAttr(resourceName, "lifecycle_policy.2.transition_to_primary_storage_class", ""),
),
},
{
Config: testAccFileSystemConfig_lifecyclePolicyTransitionToArchive(
"transition_to_ia",
Expand Down Expand Up @@ -694,6 +717,26 @@ resource "aws_efs_file_system" "test" {
`, lpName1, lpVal1, lpName2, lpVal2)
}

func testAccFileSystemConfig_lifecyclePolicyAll(lpName1, lpVal1, lpName2, lpVal2, lpName3, lpVal3 string) string {
return fmt.Sprintf(`
resource "aws_efs_file_system" "test" {
throughput_mode = "elastic"
lifecycle_policy {
%[1]s = %[2]q
}
lifecycle_policy {
%[3]s = %[4]q
}
lifecycle_policy {
%[5]s = %[6]q
}
}
`, lpName1, lpVal1, lpName2, lpVal2, lpName3, lpVal3)
}

func testAccFileSystemConfig_lifecyclePolicyTransitionToArchive(lpName1, lpVal1, lpName2, lpVal2 string) string {
return fmt.Sprintf(`
resource "aws_efs_file_system" "test" {
Expand Down
20 changes: 12 additions & 8 deletions website/docs/r/efs_file_system.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,28 @@ system creation. By default generated by Terraform. See [Elastic File System](ht
user guide for more information.
* `encrypted` - (Optional) If true, the disk will be encrypted.
* `kms_key_id` - (Optional) The ARN for the KMS encryption key. When specifying kms_key_id, encrypted needs to be set to true.
* `lifecycle_policy` - (Optional) A file system [lifecycle policy](https://docs.aws.amazon.com/efs/latest/ug/API_LifecyclePolicy.html) object (documented below).
* `protection` - (Optional) A file system [protection](https://docs.aws.amazon.com/efs/latest/ug/API_FileSystemProtectionDescription.html) object (documented below).
* `lifecycle_policy` - (Optional) A file system [lifecycle policy](https://docs.aws.amazon.com/efs/latest/ug/API_LifecyclePolicy.html) object. See [`lifecycle_policy` block](#lifecycle_policy-block) below for details.
* `protection` - (Optional) A file system [protection](https://docs.aws.amazon.com/efs/latest/ug/API_FileSystemProtectionDescription.html) object. See [`protection` block](#protection-block) below for details.
* `performance_mode` - (Optional) The file system performance mode. Can be either `"generalPurpose"` or `"maxIO"` (Default: `"generalPurpose"`).
* `provisioned_throughput_in_mibps` - (Optional) The throughput, measured in MiB/s, that you want to provision for the file system. Only applicable with `throughput_mode` set to `provisioned`.
* `tags` - (Optional) A map of tags to assign to the file system. If configured with a provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level.
* `throughput_mode` - (Optional) Throughput mode for the file system. Defaults to `bursting`. Valid values: `bursting`, `provisioned`, or `elastic`. When using `provisioned`, also set `provisioned_throughput_in_mibps`.

### Lifecycle Policy Arguments
### `lifecycle_policy` Block

`lifecycle_policy` supports the following arguments:
Describes a policy used by Lifecycle management that specifies when to transition files into and out of storage classes. For more information, see [Managing file system storage](https://docs.aws.amazon.com/efs/latest/ug/lifecycle-management-efs.html).

* `transition_to_ia` - (Optional) Indicates how long it takes to transition files to the IA storage class. Valid values: `AFTER_1_DAY`, `AFTER_7_DAYS`, `AFTER_14_DAYS`, `AFTER_30_DAYS`, `AFTER_60_DAYS`, or `AFTER_90_DAYS`.
The `lifecycle_policy` block supports the following arguments:

* `transition_to_archive` - (Optional) Indicates how long it takes to transition files to the archive storage class. Requires transition_to_ia, Elastic Throughput and General Purpose performance mode. Valid values: `AFTER_1_DAY`, `AFTER_7_DAYS`, `AFTER_14_DAYS`, `AFTER_30_DAYS`, `AFTER_60_DAYS`, `AFTER_90_DAYS`, `AFTER_180_DAYS`, `AFTER_270_DAYS`, or `AFTER_365_DAYS`.
* `transition_to_ia` - (Optional) Indicates how long it takes to transition files to the IA storage class. Valid values: `AFTER_1_DAY`, `AFTER_7_DAYS`, `AFTER_14_DAYS`, `AFTER_30_DAYS`, `AFTER_60_DAYS`, `AFTER_90_DAYS`, `AFTER_180_DAYS`, `AFTER_270_DAYS`, or `AFTER_365_DAYS`.
* `transition_to_primary_storage_class` - (Optional) Describes the policy used to transition a file from infequent access storage to primary storage. Valid values: `AFTER_1_ACCESS`.
* `transition_to_archive` - (Optional) Indicates how long it takes to transition files to the archive storage class. Requires transition_to_ia, Elastic Throughput and General Purpose performance mode. Valid values: `AFTER_1_DAY`, `AFTER_7_DAYS`, `AFTER_14_DAYS`, `AFTER_30_DAYS`, `AFTER_60_DAYS`, or `AFTER_90_DAYS`.

### Protection Arguments
### `protection` Block

Describes the protection on a file system.

`protection` supports the following arguments:
The `protection` block supports the following arguments:

* `replication_overwrite` - (Optional) Indicates whether replication overwrite protection is enabled. Valid values: `ENABLED` or `DISABLED`.

Expand Down