forked from serverless/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandler.js
More file actions
24 lines (23 loc) · 811 Bytes
/
handler.js
File metadata and controls
24 lines (23 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* eslint-disable */
/* aws-sdk automatically included in lambda context */
const aws = require('aws-sdk');
module.exports.recursiveLambda = (event, context, callback) => {
const lambda = new aws.Lambda();
console.log('received', event);
/* if numberOfCalls still has value, continue recursive operation */
if (event.numberOfCalls > 0) {
console.log('recursive call');
/* decrement numberOfCalls so we don't infinitely loop */
event.numberOfCalls = event.numberOfCalls - 1;
const params = {
FunctionName: context.functionName,
InvocationType: 'Event',
Payload: JSON.stringify(event),
Qualifier: context.functionVersion
};
lambda.invoke(params, context.done);
} else {
console.log('recursive call finished');
context.succeed('finished');
}
};