hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.65k stars 9.03k forks source link

aws_efs_file_system lifecycle_policy continues to fail with more than one argument #21862

Closed alvintownsend closed 5 days ago

alvintownsend commented 2 years ago

Community Note

Terraform CLI and Terraform AWS Provider Version

terraform --version
Terraform v1.0.6
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v3.66.0

Affected Resource(s)

Terraform Configuration Files

resource "aws_efs_file_system" "my_efs" {
  performance_mode = "generalPurpose"
  throughput_mode  = "bursting"
  encrypted        = "true"

  lifecycle {
    prevent_destroy = true
  }

  lifecycle_policy {
    transition_to_ia                    = "AFTER_30_DAYS"
    transition_to_primary_storage_class = "AFTER_1_ACCESS"
  }

  tags = {
    Name = "my-efs"
  }
}

Expected Behavior

I had an existing Terraform AWS EFS volume without a lifecycle_policy. I subsequently added the lifecycle_policy as noted above.

It is expected that the lifecycle_policy with both the transition_to_ia and transition_to_primary_storage_class would be set to their respective values.

Actual Behavior

I received the following error:

aws_efs_file_system.my_efs: Modifying... [id=fs-063483dac5b7b61af]

│ Error: error updating EFS file system (fs-xxx) lifecycle configuration: BadRequest: One or more LifecyclePolicy objects specified are malformed.
│ {
│   RespMetadata: {
│     StatusCode: 400,
│     RequestID: "9afe1f37-5a77-4988-9ab8-dfca9eeef7dd"
│   },
│   ErrorCode: "BadRequest",
│   Message_: "One or more LifecyclePolicy objects specified are malformed."
│ }
│ 
│   with aws_efs_file_system.my_efs,
│   on efs.tf line 1, in resource "aws_efs_file_system" "my_efs":
│    1: resource "aws_efs_file_system" "my_efs" {
│ 

Steps to Reproduce

  1. terraform plan -out my.plan
  2. terraform apply my.plan

Important Factoids

The lifecycle_policy works fine with just one of the values:

  lifecycle_policy {
    transition_to_ia                    = "AFTER_30_DAYS"
  }

or

  lifecycle_policy {
    transition_to_primary_storage_class = "AFTER_1_ACCESS"
  }

but never both in the same block.

I've also tried applying with just one (the transition_to_ia) and then adding the second (transition_to_primary_storage_class) with a second apply, but I get the same error message.

What does work but is unclear from the documentation:

  lifecycle_policy {
    transition_to_ia                    = "AFTER_30_DAYS"
  }

  lifecycle_policy {
    transition_to_primary_storage_class = "AFTER_1_ACCESS"
  }

References

vparmeland commented 2 years ago

Same issue with aws provider hashicorp/aws v3.68.0

vparmeland commented 2 years ago

Hello, any update ?

lpossamai commented 2 years ago

Same issue with provider hashicorp/aws v3.61.0.

lpossamai commented 2 years ago

Same issue with provider hashicorp/aws v3.61.0.

This worked for me, as a workaround:

  lifecycle_policy {
    transition_to_ia                    = "AFTER_14_DAYS"
  }

  lifecycle_policy {
    # https://github.com/hashicorp/terraform-provider-aws/issues/21862
    transition_to_primary_storage_class = "AFTER_1_ACCESS"
  }
jornfranke commented 2 years ago

https://github.com/hashicorp/terraform-provider-aws/issues/25482

github-actions[bot] commented 1 month ago

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!