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年前491ビュー
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
回答済み 1年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ