2
votes

i am storing objects to S3, i would like that object never accessed in the last month go to glacier.

After some research i don't think i can achieve this, but i hope to be wrong.

When creating lifecycle for an s3 bucket the rule is based on object creation date (not last access date)

Setting the storage class for the object will not help according to http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html

"You cannot associate an object with the Glacier storage class as you upload it. You transition existing Amazon S3 objects to the Glacier storage class by using lifecycle management. For more information, see Object Lifecycle Management."

Does anyone know how can achieve this?

Thanks

3
I am thinking that maybe i can rewrite metadata of the object to refresh creation date of the objectRiccardo Casatta
You can reset the creation date time with a command like "aws s3api copy-object --storage-class STANDARD --copy-source $bucket/$file --bucket $bucket --key $file" I wrote an article about this here: alestic.com/2013/09/s3-lifecycle-extendEric Hammond

3 Answers

4
votes

You cannot add conditional policies that apply to objects in S3 object lifecycle configuration which in your case is, is based on the object's last access time.

You can however transition objects to Glacier based on their age or on a specific date.

I would like to think you can handle it in your application but the s3 object returned does not have the last access time, if you use the the AWS SDK.

Details here

0
votes

For associate Glacier storage class to objects you need to apply lifecycle transition rule on objects.

For example, If you applied a lifecycle rule to move everything under "folder1" into Glacier, Then this rule is applied to existing data as well as on newly uploaded data on "folder1". When data is moved to Glacier then you can see that the storage class becomes Glacier

When you delete a lifecycle rule then no new data will move into Glacier but old data will still sit in Glacier until you restore them.

For more detail : Amazon S3 - Object Lifecycle Management

(Disclosure : Bucket Explorer)

0
votes

AFAIK, you can 'only' toy around with the lifecycle rules to set a fixed archiving date after object creation...