I have an AWS Lambda function, that need's ~ 30 seconds. When I connect it to the API Gateway, it's sending a 504 because of the 5-second timeout. So my easyCron Job is failing and will not try it again (I only have a free plan)
So I need an API, that sends a correct 200 status. My Idea:
Invoke the long term lambda via a short term lambda. The policy is allowing the invocation.
Here is the code
var AWS = require('aws-sdk'),
params = {
FunctionName: 'cctv',
InvocationType: 'RequestResponse',
LogType: 'Tail'
},
lambda;
AWS.config.update({region: 'us-east-1'});
lambda = new AWS.Lambda();
exports.handler = function (event, context) {
'use strict';
lambda.invoke(params, function (err, data) {
if (err) {
console.log(err, err.stack);
}
else {
console.log(data);
}
});
context.succeed('hey cron job, I think my lambda function is not called');
};
But I think, context.succeed() aborts the execution of lambda.invoke()
Do you have any idea how to solve this?