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:
- signed_2020_04_15.pdf
- signed_2020_04_17.pdf
- unsigned_2020_04_15.pdf
- unsigned_2020_04_17.pdf
- info/signed_2020_04_16.pdf
- 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?