I need to calculate the task on my Fargate cluster and after finishing calculating the task should be stopped or terminated to decrease payments.
The consequence of my actions:
- One task always running on EC2 Cluster and checking DB to the new data.
- If new data appears, Boto3 runs the Fargate container.
- After the job is done, the task should be stopped.
Also if in the DB appears the second row of data during proceeding the first task, Fargate should create a second task for the second job. and then stop tasks...
So, I have:
- Task written on Python and deployed on ECR
- Fargate cluster
- Task definition (describe Memory, CPU's and container)
How task know, that it should be closed? Any idea or solution to stop task after job done?