how we can delete files of s3bucket automatically having a certain pattern i.e folder names containing run after 180 days?
run01 run02 run03 name01
o/p: only the first 3 folders containing 'run' in its name should get deleted after 180 days
- was trying s3 bucket life cycle rule but seems it does not support regex
would appreciate any help
CodePudding user response:
AWS S3
does not support this functionality out of the box. They do not have any lifecycle policy that would delete or move objects based on the object names
. You can use the AWS CLI to fetch all the files, filter them and then delete the files that match the regex.
You could try this
aws s3 rm <your_bucket_name> --exclude "*" --include "run*"