Explore Courses Blog Tutorials Interview Questions
0 votes
in AWS by (19.1k points)

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'



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 {




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?

1 Answer

0 votes
by (44.4k points)

The right answer is this:

InvocationType: 'Event'

Not this:

InvocationType: 'RequestResponse'

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer

Browse Categories