Reputation: 890
How can I recursively call lambda inside itself in sam local environment?
const AWS = require('aws-sdk');
const lambda = new AWS.Lambda();
exports.foo = async(event, context) => {
// .......
lambda.invoke({ FuncitonName: context.functionName, InvocationType: 'Event', Payload: {/* .... */}})
}
This apparently does not work.
EDIT
My usecase is to split data to prevent timeout.
Payload
contains page number and this lambda fetches data from API with the page number and put it to DynamoDB.
Returning result to caller is not important so async invocation is fine.
Upvotes: 0
Views: 316
Reputation: 3197
If you need to call other function I would recommend using localstack
which has better support working with lambda functions locally and inter-calls between them.
sam local
is fine if you work only with the function itself but once you have integration with s3, dynamodb, sqs, lambda better to use localstack
Upvotes: 1