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년 전

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

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

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

관련 콘텐츠