Home > OS >  How do I know when an async aws lambda ends?
How do I know when an async aws lambda ends?

Time:01-04

It will be easier to understand if you look at the image:

Flow diagram

I am coding using AWS Lambda in node.js.

exports.handler = async (event) => {

const payload = 'hello from lambda 1';

const params = {
    FunctionName: 'lambda2',
    InvocationType: 'Event',
    Payload: JSON.stringify(payload),
};

const LambdaPromise = (params) => lambda.invoke(params).promise();

const responseFromLambda2 = await LambdaPromise(params);

return responseFromLambda2; //this should return {StatusCode: 202, Payload: ''}
};

I tried referring to the code above, but it failed.

A lambda invokes B lambda. And B lambda invokes many C lambdas asynchronously.

How do I know that B lambda ends with C lambdas?

I can't do this so Lambda A doesn't know if lambda B did its job properly.

CodePudding user response:

The scenario you describe is ideal for AWS Step Functions:

Step Functions is a serverless orchestration service that lets you combine AWS Lambda functions and other AWS services to build business-critical applications. Through Step Functions' graphical console, you see your application’s workflow as a series of event-driven steps.

AWS Step Functions

  •  Tags:  
  • Related