2
votes

I want to delete the previous versions of files in an S3 bucket that are not in a folder but directly uploaded in a bucket and also with a specific prefix. Eg. Some S3 keys are like:

  1. signed_2020_04_15.pdf
  2. signed_2020_04_17.pdf
  3. unsigned_2020_04_15.pdf
  4. unsigned_2020_04_17.pdf
  5. info/signed_2020_04_16.pdf
  6. info/unsigned_2020_04_16.pdf

So I want my lifecycle to delete only the previous versions of the files starting with signed_ but not the ones in the folder info. That means in the above list only signed_2020_04_15.pdf and signed_2020_04_17.pdf must be deleted.

How do I put my prefix? I tried prefix as signed_ and waited for the lifecycle policy to run but it doesn't work. But in another bucket, the prefix was like folder/ and it works.

So, do lifecycle policies work only for the files that are in a folder and not the ones that are uploaded directly?

1

1 Answers

2
votes

Edit: It works after 48 hours with prefix signed_. Just that AWS takes a bit more time is all.