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
posta 5 anni fa1390 visualizzazioni
1 Risposta
0

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

aario
con risposta 5 anni fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande