File upload and processing via AWS Lambda with response

Viewed 699

My goal is to upload a .zip file containing a python project, process it and return a json. To do that I have implemented a webapp, which takes the .zip file via drag and drop. I want to process this .zip file with AWS Lambda and return a json to the webapp, but since Lambda has to receive, unzip and read the files it forces me to use S3 I guess. I can make a direct upload from my webapps javascript to S3 and let S3 trigger Lambda for each uploaded file. But then I lose this typical request response semantic between my webapp and Lambda, since S3 trigger to Lambda are async and this way Lambda wouldn't know who to respond.

I guess my question is somehow conceptual, so how can I basically send a request from my webapp in any way shape or form so that lambda can process a file sent by my webapp and send a response, in form of a json containing some info, back to the webapp?

1 Answers

You can not really have synchronous processing here. API Gateway will limit the Lambda response time to 29 seconds, so if your files are really small, you most likely wont be able to fit into this period.

What I suggest doing is the following:

Upload the file to S3 and trigger a Lambda after the the upload did successfully finished. Process the file with a Lambda function (this can run for 15 minutes). When the processing did finish, save the output into a known location, for example a DynamoDB table. You can poll this location from the front-end for being able to see if the processing did finished.

Related