Home > Mobile >  Return value of the Lambda can be seen by response of API gateway?
Return value of the Lambda can be seen by response of API gateway?

Time:05-05

I'm trying to implement the following structure on my AWS account. I'll upload a picture to my s3 bucket with a put/post request and process the following picture with Textract. API call for the Textract will be handled by Lamda. So here is the question. Will the response of the lambda be my response to put/post request? I mean when I put/post via API gateway there got to be a response. I'd like to see this response content from Lambda's response. Is it possible by the following structure?

enter image description here

CodePudding user response:

The response to the PUT/POST request will be a 200 OK response indicating that the file was successfully uploaded to S3. The API Gateway response will be returned as soon as the file upload to S3 is completed. As far as API Gateway knows the entire process is done at that point. The S3 trigger that invokes your Lambda function happens asynchronously, after your S3 upload has completed, so that can't be involved in the response to the PUT/POST request.

CodePudding user response:

There are two parts here and, in your current diagram, what you want to do isn't possible directly. The S3 to Lambda call is not part of the same flow - it is done for you by AWS and you don't have direct control over it.

Additionally, it may take some time to do the extraction, depending on the complexity of the documents uploaded. Not hours but not instantaneously either.

So it will need to change to a disconnected model where the request is sent off and then some time later you either poll for a result or are notified that a result is available.

Conceptually, more like this:

enter image description here

  • Related