Is there a way to not change an S3 object's Last-Modified date when copying it to a new bucket?

0

I'm trying to copy existing S3 objects to another S3 bucket. As far as I know, there are two ways to do that at scale: S3 Batch Operations and Replication. According to AWS documentation, both solutions support copying object metadata in addition to the object itself.

However, when I tried copying the S3 objects using S3 Batch Operations, the Last-Modified metadata was updated to the timestamp when each object was copied. The objects themselves and the rest of their original metadata was copied over to the new S3 bucket without being changed.

Is there a way to copy an S3 object's original Last-Modified metadata when using S3 Batch Operations or Replication without it being changed?

AWS
asked 4 years ago4214 views
2 Answers
0
Accepted Answer

System-defined object metadata, which includes an S3 object's Last-Modified date, can be modified by Amazon S3 only.

To retain an S3 object's original Last-Modified date when it's copied, you can add user-defined metadata to the object. For more information, see Editing object metadata in the Amazon S3 console.

AWS
answered 4 years ago
0

In addition to the workaround, of using a new user-metadata field, you can also retain the last-modified date as system-defined object metadata when copying to another bucket via Replication. When objects are replicated from one bucket to anther, both source and destination have the same system-defined last-modified date.

Replicate objects while retaining metadata – You can use replication to make copies of your objects that retain all metadata, such as the original object creation times and version IDs. This capability is important if you must ensure that your replica is identical to the source object. https://docs.aws.amazon.com/AmazonS3/latest/userguide/replication.html#replication-scenario

This also applies to S3 Batch Replication which wasn't available when this question was first asked, but released in February 2022.

This is unique to S3 Replication, and not supported by other S3 Batch Operations, such as the Copy Object Operation.

profile pictureAWS
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.

Guidelines for Answering Questions