Skip to content

Add tagging support for the s3 cp, mv, and sync commands#10370

Open
sveniu-kahoot wants to merge 2 commits into
aws:developfrom
sveniu-kahoot:s3-tags-on-upload-v1
Open

Add tagging support for the s3 cp, mv, and sync commands#10370
sveniu-kahoot wants to merge 2 commits into
aws:developfrom
sveniu-kahoot:s3-tags-on-upload-v1

Conversation

@sveniu-kahoot
Copy link
Copy Markdown

Issue #, if available:

#2458

Description of changes:

This adds object tagging to the s3 transfer commands, scoped to uploads. It reuses the existing RequestParamsMapper/extra_args path that --metadata and the recently merged s3 mb --tags (#10119) already use, so it applies on both the classic and CRT transfer clients without changing how the transfer client or config are obtained. An earlier, broader attempt (#6079) was closed as not-planned; this version is intentionally narrower, leaving S3-to-S3 copies to --copy-props.

  • Add a --tags parameter to aws s3 cp, aws s3 mv, and aws s3 sync to set object tags at upload time, avoiding a separate put-object-tagging request. Mirrors the aws s3 mb --tags syntax.
  • The pairs are URL-encoded into the Tagging parameter, which s3transfer applies to PutObject (single-shot) and CreateMultipartUpload (multipart) and excludes from the part uploads.
  • Like other write-time property flags, tags apply only to objects actually uploaded; in a sync, unchanged files are not retagged. S3-to-S3 copies remain governed by --copy-props.
  • Added unit and functional tests, command examples, and a changelog entry.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

The aws s3 cp/mv/sync commands already let users set most write-time
object properties (storage class, metadata, SSE, ...) but not tags,
forcing a separate PutObjectTagging pass after the transfer. That pass
doubles the request count, and any object whose tagging step is skipped
or fails stays untagged, so tag-based lifecycle rules never match it.

Teach RequestParamsMapper to build the Tagging member of PutObject and
CreateMultipartUpload from the repeatable --tags key/value pairs,
URL-encoding them into the x-amz-tagging query-string form. s3transfer
forwards these extra args to CreateMultipartUpload and drops them from
the per-part requests, so the tag set is applied to the object exactly
once regardless of size.

This commit only adds the mapping; no CLI parameter feeds it yet, so it
is inert on its own.
Expose the object tagging support wired into RequestParamsMapper as a
--tags parameter on the transfer commands. It takes repeatable
--tags <key> <value> pairs, matching the s3 mb --tags syntax, and
applies them to each object as it is created.

Like every other write-time property, it only affects objects that are
actually uploaded; in a sync, files that have not changed are not
retagged. This matches the long-standing behaviour of --metadata,
--storage-class and --acl and is called out in the parameter's help
text. S3-to-S3 copies remain governed by --copy-props and are
intentionally out of scope for this change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant