I am trying to write a lambda function that triggers many small lambdas
exports.handler = (event, context, callback) => {
var AWS = require('aws-sdk');
let noOfPages = 20, currentPage = 1;
var message = '';
//let payloadArray = [];
while(currentPage <= noOfPages){
message = '{"first_page": '+ currentPage +', "last_page": '+ (currentPage) + ', "file_name" : "something.doc"' +'}';
console.log(message);
var params = {
FunctionName: 'test',
InvocationType: 'Event',
LogType: 'Tail',
Payload: message
};
var convLambda = new AWS.Lambda({
accessKeyId: 'key',
secretAccessKey: 'secret',
region: 'us-west-2'
});
convLambda.invoke(params, function(err, data) {
if (err) {
context.fail(err);
} else {
context.succeed('Processed : '+ data);
}
})
currentPage+=1;
}
};
This works well and triggers, say 20 lambdas. I would however, like to wait till all the async lambdas are done (fork and join). Is there way to achieve this currently in Amazon Lambda?
You could consider using AWS Step Functions, which can fork and join Lambda processes. It also shows the relationships in pretty graphs:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With