Tag-based filtering in replication rules

Replication rules can use object tags to determine which objects are replicated to a destination bucket.

Rule versions

V1 rules (legacy)

  • Use Prefix directly under Rule
  • Do not support tag filtering

V2 rules

  • Use a Filter element
  • Support tag-based filtering

Filter types

Single tag filter

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

Prefix filter

Matches objects based on key prefix.

<Rule>
  <Filter>
    <Prefix>prefix</Prefix>
  </Filter>
</Rule>

And filter

Combines Prefix and one or more Tag elements. All conditions must match.

<Rule>
  <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>
    </And>
  </Filter>
</Rule>

Empty filter

Replicates all objects in the bucket.

Tag matching behavior

  • Exact key-value match required.
  • Matching is case-sensitive.
  • Multiple tags use AND logic.
  • All specified tags must match.