-4

I found a way to trigger the aws lambda function at a point of time like after every 5 minutes or 20 hours whatever but searched whole through the internet and was unable to find how to trigger it automatically and make that event to get inside app.get('/cron/job') method.

No doubt the lambda function will trigger after any time that we specify, that is working for me. But my problem is that I am unable to make the lambda after every trigger to enter into app.get('/cron/job').Means not whole of the lambda but just a code in lambda. How to do that.

Please any help would be fine.

learner
  • 503
  • 2
  • 8
  • 15
  • Thanks Sir, but I already saw this link http://stackoverflow.com/questions/27382009/aws-lambda-scheduled-tasks it didn't solved my problem. No doubt the lambda function can trigger after every 24 hours. But my problem is that I am unable to make the lambda after every trigger to enter into app.get('/cron/job'). How to do that. Thanks @Anthony sir for specifying my query properly. – learner Apr 20 '17 at 13:18

3 Answers3

0

You can create a Lambda function and direct AWS Lambda to execute it on a regular schedule. http://docs.aws.amazon.com/lambda/latest/dg/with-scheduled-events.html

Balaji
  • 1,028
  • 8
  • 12
  • FYI, there's a deleted answer to this question making the same suggestion. This isn't what the OP wants unfortunately; they want to literally call `app.get('/cron/job')` on trigger. – Anthony Neace Apr 19 '17 at 20:37
0

I solved it by : 1) Making the use of request module to call the exact api with path i.e.,

    request({
     headers: "your header",
     url : "/path/cronjob",
     method :'POST',
     body: data,
     json: true
   }, function(err, res, body){}

instead of using lambda.invoke()

2) And adding the api gateway method like 'POST' and mapping the lambda function with the function to be called with the path : /path/cronjob

learner
  • 503
  • 2
  • 8
  • 15
0

To trigger a Lambda function once every 20 or 24 hours, we can schedule a trigger in CloudWatch Events.

CloudWatch Events allows targets to be triggered using a Schedule Expression. A Schedule Expression can define a rate; for example, every 24 hours. Or can accept a standard cron job expression.

CloudWatch Events supports many targets, including Lambda.

Also, there are a few great answers on this stackoverflow link AWS Lambda Scheduled Tasks