1
votes

I'm looking to delete S3 objects after they're not used for a certain amount of time.

Specifically, there should be two rules:

  1. move them to glacier after a certain time they're unused (6 months)
  2. delete them after they've been in glacier for 2 weeks

The objects are in a versioned bucket. I also know that there's a deletion fee for glacier objects deleted before 90 days, but that's not a problem.

Now, I can easily accomplish objective 1 via an Intelligent-Tiering Archive configuration.

However, I don't know if it's possible to accomplish object 2 - when I look at the lifecycle rules, I can't find a way to specify that I want to delete all the versions (current and past) of an object that has been in Glacier (Archive) for 2 weeks.

The only way I can think of modeling this problem is:

  • Create an "Intelligent-Tiering Archive configuration" that moves to archive after 6 months, and to deep archive after 2 weeks
  • Create a lambda that expires and deletes all the version of objects in deep archive.

This has two disadvantages:

  • I'll pay for deep archive storage even if it's virtually unused (but that's not a big deal)
  • I'll need to write a Lambda

Is there a simpler solution?

1

1 Answers

0
votes

There's no need to move to deep glacier, in order to detect how long an object has been in the glacier class.

When an object class is converted, an new version is created, which carries the updated timestamp in the LastModified field, which can be queried, in order to decide if an object should be deleted or not.

Regarding the deletion itself, there's no automated way to do that.