0

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

hburak_06
  • 25
  • 9

2 Answers2

2

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

stdunbar
  • 16,263
  • 11
  • 31
  • 53
  • Hello, first of all thanks for your comments. As far as I see from the cloudwatch it tooks 3 seconds to handle processing the image when Lambda is triggered. So, here is the next question according to your flow. How do I have to arrange the SNS to get response. I mean should there be a frequent request to AWS? – hburak_06 May 05 '22 at 12:43
  • I don't understand the usage of SNS right here. Why it's required could you please explain it? – hburak_06 May 16 '22 at 07:09
  • Once the processing is done a notification needs to go back to the user. This can be done in a variety of ways but one possible way is via [SNS push notifications](https://docs.aws.amazon.com/sns/latest/dg/sns-mobile-application-as-subscriber.html) – stdunbar May 17 '22 at 16:08
1

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.

Mark B
  • 183,023
  • 24
  • 297
  • 295
  • Hello, first of all thanks for your comments. Is there any way to get Lambdas response without saving to database? – hburak_06 May 05 '22 at 12:49