Skip to content

TF recreates rules when it should not #42894

Closed as duplicate of#34645
Closed as duplicate of#34645
@EugenKon

Description

@EugenKon

Terraform and AWS Provider Version

Terraform v1.11.4
on darwin_arm64

Affected Resource(s) or Data Source(s)

  • aws_s3_bucket_lifecycle_configuration

Expected Behavior

I added new rule, TF should just create it.

Actual Behavior

I added new rule, but TF recreates the existing one.

Relevant Error/Panic Output

  # module.private-cloud.aws_s3_bucket_lifecycle_configuration.iguides-s3 will be updated in-place
...
      ~ rule {
          ~ id     = "draft-queue" -> "delete-stitch-data/-1year"
            # (2 unchanged attributes hidden)

          ~ expiration {
              ~ days                         = 30 -> 365
                # (1 unchanged attribute hidden)
            }

          ~ filter {
              ~ prefix = "draft-queue/" -> "stitch-data/"
            }
        }
...
      + rule {
          + id     = "draft-queue"
          + status = "Enabled"
            # (1 unchanged attribute hidden)

          + expiration {
              + days                         = 30
              + expired_object_delete_marker = false
            }

          + filter {
              + prefix = "draft-queue/"
            }
        }

Sample Terraform Configuration

Click to expand configuration
resource "aws_s3_bucket_lifecycle_configuration" "iguides-s3" {
  bucket = aws_s3_bucket.iguides-s3.id

  # Delete stitch data after 1 year
  rule {
    id     = "delete-stitch-data/-1year"
    status = "Enabled"

    filter {
      prefix = "stitch-data/"
    }

    expiration {
      days                         = 365
      expired_object_delete_marker = false
    }
  }

  # Delete draft-queue/ after 30 days
  rule {
    id     = "draft-queue"
    status = "Enabled"

    filter {
      prefix = "draft-queue/"
    }

    expiration {
      days = 30
    }
  }
}
+  # Delete stitch data after 1 year
+  rule {
+    id     = "delete-stitch-data/-1year"
+    status = "Enabled"
+
+    filter {
+      prefix = "stitch-data/"
+    }
+
+    expiration {
+      days                         = 365
+      expired_object_delete_marker = false
+    }
+  }

Steps to Reproduce

  1. Create lyfecycle with one rule
  2. plan/apply
  3. Add another rule before the first one
  4. plan/apply
    TF will replace the first rule, though it should just add the new one.

Debug Logging

Click to expand log output

GenAI / LLM Assisted Development

n/a

Important Facts and References

Probably this belongs to:
#42202

There also array of some items and how TF works with them.

Would you like to implement a fix?

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAddresses a defect in current functionality.service/s3Issues and PRs that pertain to the s3 service.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions