user3195078
user3195078

Reputation: 11

In Lambda is it possible to get the result of a callback before the process finishes?

I'm currently implementing a webservice with lambda and api gateway. I don't want to delay the response of the service because it is just a redirection, but in the background I'm doing some actions. Is it possible to return something to the client before the action is finsished ?

Thank you very much

Upvotes: 0

Views: 91

Answers (1)

Luc Hendriks
Luc Hendriks

Reputation: 2533

You can do this with Node.js, but the Lambda/API Gateway model is not really designed for this.

What you can do (we do this in our live environments as well) is the following:

Lambda function A is reachable via API Gateway. Lambda A receives a request, saves a "job definition" file in an S3 bucket and sends a response to the user that the request has been received.

Lambda function B is not reachable via the API Gateway, but has the "object created" S3 event trigger. This lambda function is triggered because Lambda A created an object in the bucket and parses the background job.

Upvotes: 1

Related Questions