aldm
aldm

Reputation: 379

Deploying cron job node.js script to AWS

I am pretty new to AWS. We're looking for a way to execute our node.js script like a cron job. There is Elastic Beanstalk application which runs a web server in node. In the same git repository, we'll have a few lightweight services that will run periodically, probably one minute, to clean something from DB, sync some external data etc, nothing major.

What would be the best way to do this? I would like to avoid using lambda, since we want the code to be locally testable and present in the repository.

Thanks in advance

Upvotes: 1

Views: 1145

Answers (2)

Ankush Jain
Ankush Jain

Reputation: 7049

You could do it using following steps:

  1. Expose some public secure end-points (web-hook endpoints) to perform the intended job.
  2. Create an EventBridge Rule to invoke those Http Endpoints on a scheduled basis using some CRON Expression.

Note: Don't expose those public endpoints without any authorization.

Here is an screenshot of EventBridge from AWS Console.

enter image description here

Reference - Using API destinations with Amazon EventBridge

Upvotes: 1

sytech
sytech

Reputation: 40891

Any service that can be subscribed to scheduled CloudWatch events.

If you don't want to use Lambda, you could use ECS/Fargate to run scheduled tasks. The short version is it's basically docker run on a cron schedule made easy.

Upvotes: 1

Related Questions