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 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南