Amazon S3 – Understanding S3 Lifecycle Rules

amazon s3amazon-glacieramazon-web-services

I am working on an e-commerce website.

I store product photos in an s3 bucket. Once the product is deleted, I also delete the photos from s3 bucket.

I have S3 bucket versioning enabled. I am not entirely sure how does versioning wortk?

Here are my assumptions:

  1. If a product photo is modified, the old photo is kept with an old version (so the old photo is never deleted)
  2. If a photo is deleted, AWS still keeps the deleted photo however it is marked as deleted

Are the above assumptions correct?

Now I want create a Lifecycle rule to move the old photos (deleted or the old version of modified photos) to a cheaper storage.

From S3 Console, I choose Management > Create lifecycle rule. I can see the following options:

  • Move current versions of objects between storage classes
  • Move noncurrent versions of objects between storage classes
  • Expire current versions of objects
  • Permanently delete noncurrent versions of objects
  • Delete expired object delete markers or incomplete multipart uploads

I am not clear what does noncurrent version mean?

Is a deleted photo a noncurrent version? What about a product photo which remains active for a very long time (say 1 year) without being modified or deleted… does it ever become noncurrent, because it has been sitting in the bucket for too long?

I think the option that I want is this:

enter image description here

Does the above rule move deleted and modified photos to a cheaper storage, after 30 days?

Best Answer

Your understanding is correct about how versioning works, and what the lifecycle rule is doing.

You should consider using glacier instant retrieval class to save more money, or Glacier Deep Archive if you're ok with a six month minimum storage period.

Note there is a small charge to transition objects between storage classes, so it's not worthwhile in some cases such as CloudTrail logs. Images it should be worthwhile. The documentation covers this well.