Reputation: 569
I have two AWS lambdas written in go. One lambda invokes the other like this:
payload, err := json.Marshal(request)
if err != nil {
log.Printf("ERROR: could not marshal request [%v] into model.ChildLambdaRequest - %v\n", request, err)
return false
}
log.Printf("--- debug sending payload: %s", payload)
// Invoke Child
result, err := client.Invoke(&lambda.InvokeInput{
FunctionName: aws.String(lambdaName),
Payload: payload,
})
if err != nil {
log.Printf("ERROR: could not invoke Lambda function client [%v] - %v\n", lambdaName, err)
return false
}
The child lambda completes like this:
return model.EventResponse{Success: true}, nil
I know this is doing two things: 1.) it's finishing the execution and 2.) it's returning a value. Is there any way to separate these two actions, so that I can return a value at the top, but complete execution at a later time?
Upvotes: 1
Views: 915
Reputation: 1242
It's possible with Destinations in Lambda.
Although I would check out AWS Step Functions, which gives you this functionality together with built-in retries and error handling. It works with existing Lambda functions and has a pretty easy to use interface.
Last option that could work, you send a message from the first function to an SQS Queue, and your second lambda is triggered by the SQS Queue. This also gives you retry capabilities.
Upvotes: 0