Skip to content

[Bug]: S3 Lifecycle rule with no filter gives a warning #41725

@BroMattMiller

Description

@BroMattMiller

Terraform Core Version

1.11.1

AWS Provider Version

5.90.0

Affected Resource(s)

aws_s3_bucket_lifecycle_configuration

Expected Behavior

If I understand the provider docs correctly, it's recommend to omit both filter and prefix options from a rule that should apply to all objects in the bucket. If I do this I get such a rule in AWS, but "terraform apply" gives an "Invalid Attribute Combination" warning. No warning should be issued in this case.

Actual Behavior

The warning includes:

No attribute specified when one (and only one) of [rule[0].prefix.<.filter] is required

Relevant Error/Panic Output Snippet

Terraform Configuration Files

resource "aws_s3_bucket_lifecycle_configuration" "main" {
  for_each = toset(local.data_bucket_types)

  bucket = aws_s3_bucket.main[each.key].id

  rule {
    id     = aws_s3_bucket.main[each.key].id
    status = "Enabled"

    expiration {
      expired_object_delete_marker = true
    }

    noncurrent_version_expiration {
      noncurrent_days           = 90
      newer_noncurrent_versions = 2
    }

    abort_incomplete_multipart_upload {
      days_after_initiation = 10
    }
  }
}

Steps to Reproduce

Create a lifecycle configuration with no filter and no prefix

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

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