Tag-based filtering in lifecycle rules

Lifecycle rules can filter objects based on object tags stored in S3.

Filter types

Single tag filter

Matches objects that contain an exact tag key-value pair.

<Filter>
  <Tag>
    <Key>tag-key</Key>
    <Value>tag-value</Value>
  </Tag>
</Filter>

And filter

Combines multiple conditions. All conditions must match.

Supported elements:

  • Prefix
  • One or more Tag elements
  • ObjectSizeGreaterThan
  • ObjectSizeLessThan
<Filter>
  <And>
    <Prefix>prefix</Prefix>
    <Tag>
      <Key>tag-key-1</Key>
      <Value>tag-value-1</Value>
    </Tag>
    <Tag>
      <Key>tag-key-2</Key>
      <Value>tag-value-2</Value>
    </Tag>
    <ObjectSizeGreaterThan>1000</ObjectSizeGreaterThan>
    <ObjectSizeLessThan>10000</ObjectSizeLessThan>
  </And>
</Filter>

Empty filter

If no filter is specified, the rule applies to all objects in the bucket.

Tag matching logic

  • Tag key and value must match exactly.
  • Matching is case-sensitive.
  • Multiple Tag elements use AND logic.
  • Single missing or mismatched tag fails the filter.
  • Objects without tags do not match tag-based filters.