I am using AWS Batch to run various tasks. The problem is, for task X, there is a requirement of only one task instance X running at any given time. Required concurrency for the task X is 1.
Currently, my solution is: Every 60 minutes, EventBridge Schedule submits a Job Definition for task X to the AWS Batch Job Queue, which runs task X in a Fargate Compute Environment. Job Definition X has a timeout of 55 minutes. In this way, I have designed task X to have concurrency=1.
However, in the unlikely event someone manually submits task X Job Definition to the Job Queue, task X would have concurrency>1. This is not acceptable. Is there a way to configure AWS Batch Job Queue to RUN a task with Job Definition X only if there is one NOT already running?
Another solution I am not fond of: Every task that has to have concurrency=1 has to have its own Job Queue and Compute Environment in which the maximum vCPU is set to the vCPU required by a task in question. In such a limited compute environment, only one task can run at a time.