Rakesh
Rakesh

Reputation: 104

AWS configuration to delete files

I have a folder "Execution" folder in s3 bucket.

It has folders and files like

Execution

    Exec_06-06-2022/
        file1.json
        file2.json
    Exec_07-06-2022/
        file3.json
        file4.json

I need to configure to delete the Exec_datestamp folders and the inside files after X days.

I tried this using AWS lifecycle config for the prefix "Execution/"

But it deletes the folder Execution/ after X days ( set this to 1 day to test)

Is there any other way to achieve this?

Upvotes: 0

Views: 47

Answers (2)

Rakesh
Rakesh

Reputation: 104

Got it, https://stackoverflow.com/a/41459761/5010582. The prefix has to be "Execution/Exec" without any wildcard.

Upvotes: 0

Marcin
Marcin

Reputation: 238957

There are no folders in S3. Execution is part of objects name, specifically its key prefix. The S3 console only makes Execution to appear as a folder, but there is no such thing in S3. So your lifecycle deletes Execution/ object (not folder), because it matches your query.

You can try with Execution/Exec* filter.

Upvotes: 1

Related Questions