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
preguntada hace 5 años1390 visualizaciones
1 Respuesta
0

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

aario
respondido hace 5 años

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas