A lambda function to delete old archive files in s3 bucket

0

Hi Folks,
I need a lambda function to delete old archive files in s3 bucket. I couldn't find any sample code for that and I don't have time to read general books about AWS.
What I have is a script running on a server to make backups and upload them to an S3 bucket.
What I want is a lambda function which runs periodically and deletes old archive.
I created a lambda function but as I didn't know how to set a timer for it, I created a trigger to run it when an object is created on that bucket. Then the problem was that the function to get a list of s3 bucket objects (just to start with) was asynchronous and before the request was finished, the control would go out of the function scope. So this didn't work. I have no idea how to do this and documents online look like to be related to general use of aws sdk in self-hosted python and nodejs scripts and not in lambda.
Is there a sample code for that?
Thanks in advance.

aario
質問済み 5年前1390ビュー
1回答
0

Gave up! Instead created a bucket life cycle rule to expire objects after some time.

aario
回答済み 5年前

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

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

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

関連するコンテンツ