Skip to content

aws_s3_bucket_lifecycle_configuration empty filter block produces a warning #42714

@adrawbond-alto

Description

@adrawbond-alto

Documentation Link(s)

https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration#filter

Description

The documentation currently states that "The filter configuration block must either be specified as the empty configuration block (filter {}) or with exactly one of prefix...". However, when you specify an empty filter{} the provider now produces a warning after PR #41662.

resource "aws_s3_bucket_lifecycle_configuration" "lifecycle" {
  bucket = aws_s3_bucket.my_bucket.id

  rule {
    id = "archive-all"

    filter {}

    status = "Enabled"

    transition {
      days          = 90
      storage_class = "STANDARD_IA"
    }
  }
}

Results in this warning as of 5.90.0:

│ Warning: Invalid Attribute Combination
│ 
│   with aws_s3_bucket_lifecycle_configuration.lifecycle,
│   on main.tf line 26, in resource "aws_s3_bucket_lifecycle_configuration" "lifecycle":
│   26:     filter {}
│ 
│ No attribute specified when one (and only one) of
│ [rule[0].filter[0].prefix.<.object_size_greater_than,rule[0].filter[0].prefix.<.object_size_less_than,rule[0].filter[0].prefix.<.and,rule[0].filter[0].prefix.<.tag]
│ is required
│ 
│ This will be an error in a future version of the provider
│ 
│ (and one more similar warning elsewhere)

Setting filter { prefix = "" } fixes the warning. This should be mentioned in the documentation.

References

#41662

Would you like to implement a fix?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationIntroduces or discusses updates to documentation.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