Reputation: 3873
I have an Amazon S3 bucket and I have the following structure:
one/
inside-one/
test1/
abc/
apple/
mango/
banana/
def/
apple/
mango/
xyz/
apple/
mango/
banana/
test2/
abc/
apple/
mango/
def/
apple/
mango/
banana/
xyz/
apple/
mango/
test3/
test4/
abc/
apple/
mango/
def/
apple/
mango/
xyz/
apple/
mango/
banana/
inside-one-two/
inside-one-three/
two/
three/
And I want to delete the ONLY the /banana
directory in each directory. So I thought of writing a lifecycle-rule
with prefix
limiting the scope of this rule using one or more filters
So I added the following prefix, and I think the correct prefix for this would be:
one/inside-one/*/*/banana
Can someone help me confirm that? Is my prefix
right and it wouldn't delete anything other than following files/directories?
one/inside-one/test1/abc/banana
one/inside-one/test1/xyz/banana
one/inside-one/test2/def/banana
one/inside-one/test4/xyz/banana
Upvotes: 1
Views: 6645
Reputation: 1228
Because the wildcard asterisk character (*) is a valid character that can be used in object key names, Amazon S3 literally interprets the asterisk as a prefix or suffix filter.
So because of above this is not possible in lifecycle-rules.
https://aws.amazon.com/premiumsupport/knowledge-center/s3-event-notification-filter-wildcard/
I think best way on how to do is using a Lambda that checks the object key with your wildcard to delete these files. Use CloudWatch Events to trigger the lambda.
Upvotes: 1