How to Omit a sub folder from the Lifecycle Policy

0

I want to omit an entire sub folder from a lifecycle policy. The folder which we want to omit from the lifecycle policy is present inside the folder where we want to apply the lifecycle policy along with the rest of the data. It is not possible to move the folder outside the main folder also files may be added inside the folder in future which should also not get affected using the lifecycle policy. Is there any way we can achieve this. Note - I cannot use the object tags here because object tags can only be used on all the objects inside a folder but files will be added to the folder on a daily basis so we need to omit the whole folder rather than using the object tags for specific objects.

1개 답변
0

Unfortunately you're going to have to create rules for all folders (or actually prefixes, to use to right term) except the one you want to exclude. Regular expressions can't be used to create a rule like "all prefixes except /foo/bar".

if you can't use tags then another way round this is that if your rule is going to be "apply to everything over X days old" then once a day (or week, or month) run a job to basically do the same as the Linux touch command and change the last modified date everything in the folder so that it never falls within scope of the rule.

$ aws s3 ls s3://my-practice-bucket/downloads.zip
2023-05-11 11:42:15     105593 downloads.zip
$ aws s3 cp --metadata '{"touched":"now"}' s3://my-practice-bucket/downloads.zip s3://my-practice-bucket/downloads.zip
copy: s3://my-practice-bucket/downloads.zip to s3://my-practice-bucket/downloads.zip
$ aws s3 ls s3://my-practice-bucket/downloads.zip
2023-06-06 13:16:53     105593 downloads.zip
$

(NB I'm not sure if this will work if versioning is enabled on the bucket).

profile picture
전문가
Steve_M
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠