Search code examples
amazon-web-servicesaws-api-gatewayamazon-ecsaws-batch

Design Pattern AWS Batch calling a REST endpoint using cron


I am inexperienced with AWS, so if this is a basic question please excuse my lack of knowledge here.

This question is an architectural question.

I have set up the following on AWS so far which is working as expected. However, the part that is missing is the "Cron" (every 24 hrs) that needs to call a REST GET endpoint on the expiry-service.

I was looking at AWS Batch to run a job to call this endpoint. However, I don't see where to:

  1. Set a schedule
  2. How to get the job to invoke the REST endpoint

Question

Is AWS Batch the correct service to use? If so, how do I achieve the above to goals? Do I also need to use AWS API Gateway?

enter image description here

UPDATE

  1. I can use Amazon Event Bridge to schedule a cron to trigger a job.
  2. Need to work out how to get the job to call the REST endpoint.

Solution

  • You could do a standard ECS scheduled job instead of using AWS Batch, and just have that ECS task be some sort of script that invokes an API.

    Even standard ECS/Fargate is probably overkill for this though. I would recommend having EventBridge trigger an Lambda function instead.

    Or you could have EventBridge call the API for you directly, with no other services involved, although if you need to do something with the response from the API then that won't work.