Search code examples
amazon-web-serviceserror-handlingaws-lambdaworkflow

AWS lambda: check if function run unsuccessfully


so I know AWS lambdas as mostly a stateless thing (though I read some people built stateful-ish things around it ) so this may be an already answered question from the beginning but:

say you want to run a lambda function with an orchestrator of your own (i.e.: Airflow) and you want to deploy certain functions with lambda functions and you may continue in the pipeline ONLY if the lambda function is successful (I don't mean provision/build/stuff like that , I mean it's got an error inside it that prevents it from running). in order to do so I would have to check whether the function experienced some errors during runtime.

I know there are AWS step functions that do this in-house but for a variety of reasons we prefer not to use them. are there any way to do this?


Solution

  • It's not very clear to me what exactly you need but i would recommend AWS Step Functions if you want to coordinate lambdas.

    There is also the functionality to invoke a lambda synchronously (and wait for the response), or asynchronously (Ref).

    I have done this with Node.js (Ref):

     let params = {
      FunctionName: 'myfunction', /* required */
      InvocationType: Event | RequestResponse | DryRun,
      Payload: Buffer.from('...') || 'STRING_VALUE' /* Strings will be Base-64 encoded on your behalf */
    };
    
    await lambda.invoke(params).promise();