Search code examples
amazon-web-servicesaws-lambdaaws-cliaws-amplify

How to create aws cron job from base code?


I want to create a cron job for an amplify backend project. I want to have main job and secondary jobs. With cli i can create new lambda function as cron job (main job). But what i need is in my base code (in the lambda function body) to write a code that create/schedule new job and push it to the cloud (another lambda function or something). In short i want to create a job with code, not with cli or the web. Or i want to schedule new job as result of another job. Am using typescript/node.


Solution

  • I have a workaround through using SQS (Simple Queue Service) to send a job to another lambda function. Using SQS make required extra policies:

    "sqs:SendMessage",
    "sqs:ReceiveMessage"

    Send message for the first (main) job / lambda function. Recieve message for the second job / lambda function.