Skip to content

Can datasync operation put a tag on S3 object?

0

I am copying some data to S3 bucket as a destination location. I'd like to assign a tag to objects which are getting copied to S3 bucket via datasync copying. Is it possible?

asked a year ago213 views

2 Answers
0

Yes, it is possible to add tags to objects that are being copied to an S3 bucket using AWS DataSync. You can configure this during the task creation or modification in DataSync.

Here's how you can add tags to objects during DataSync transfer:

  1. When creating or editing a DataSync task:
    • Go to the "Configure settings" section
    • Look for "Tags" under "Object configuration"
    • Enable "Add tags to transferred objects"
    • Add your desired key-value pairs for the tags

You can do this through:

  • AWS Management Console
  • AWS CLI
  • AWS SDK

Example using AWS CLI:

aws datasync create-task \
  --source-location-arn "source-arn" \
  --destination-location-arn "destination-arn" \
  --options '{"ObjectTags": "PRESERVE"}'

Important notes:

  1. You can preserve existing tags from the source location
  2. You can add new tags during transfer
  3. Tags will be applied to all objects transferred in that task
  4. There are limits to the number of tags per object (50 tags per object in S3)
AWS

answered a year ago

  • thanks for your response.. unfortunately I am unable to find said option

    Under DataSync >>Tasks>>Create task I see

    Tags - optional A tag is a label that you assign to an AWS resource. Each tag consists of a key and an optional value.

    But this did not work as expected.

0

You're correct - the "Tags" option you're seeing in the DataSync task creation is for tagging the DataSync task itself, not the objects being transferred to S3.

For tagging objects during transfer, you have a few alternative approaches:

  1. Use S3 Bucket Default Tags:
  •     Go to your destination S3 bucket
    
  •     Under "Properties"
    
  •     Look for "Tags" section
    
  •     Add default tags that will be applied to all new objects
    
  1. Use S3 Lifecycle rules with tags
  2. Post-transfer tagging options:
  •     AWS S3 Batch Operations
    
  •     AWS Lambda function triggered by S3 events
    
  •     AWS CLI or SDK scripts
    

If you specifically need to tag objects during the transfer process, you might want to consider using AWS CLI, SDK or other transfer tools that provide more granular control over object metadata and tags.

AWS

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.