I am learning node and serverless architecture. To test my lambda function locally I am currently using lambda-local which has been working fine so far.
Now I have a function that invoke another lambda function, something like this:
let lambda = new integration.myLambda.AWS.Lambda();
let params = {
FunctionName: 'my-other-function',
InvocationType: 'RequestResponse',
LogType: 'None',
Payload: JSON.stringify(myEvent)
};
return new Promise((resolve, reject) => {
lambda.invoke(params, function (error, data) {
if (error) {
console.log('error on invoke', error);
reject({
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
message: error
});
} else {
console.log('invoke success', data);
resolve(JSON.parse(data.Payload));
}
});
});
This bit of code does not work locally, but once deployed on aws it's working fine. However deploying to aws it takes about 2 mins. So I was wondering if there is a way to have this code run locally.
Any suggestions?
Thank you!
So personally I use serverless as my preferred framework for local, there's also a very promising looking project from atlassian called localstack here - I haven't actually tried the second one! Hope this helps.
So I find out that all I need it to do was to export: accessKeyId and secretAccessKey.
Just for testing put it in code just above your invoke call. Then make sure you set them in a secure place.
I was exporting them
export ACCESS_KEY_ID=yourkey
export SECRET_ACCESS_KEY=yoursecretkey
Now I am using docker so I have them in a config file.
Hope this helps