By using AWS re:Post, you agree to the Terms of Use
/Fargate: how to stop task after finishing/

Fargate: how to stop task after finishing


Hello. I need to calculate the PDF task on my Fargate cluster and after finishing calculating the task should be stopped or terminated to decrease payments.

The consequence of my actions: 1. Little task always running on EC2 Cluster and check DB to the new data. 2. If new data appears, using Boto3, run the Fargate container (big task to calculate PDF). 3. 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:

  • PDF task written on Python and deployed on ECR
  • Fargate cluster
  • Task definition (describe Memory, CPU's and container)

What is my next step? How task know, that it should be closed? Any idea or solution?

1 Answers
Accepted Answer

An ECS task (regardless of whether it's using EC2 or Fargate) exits when an essential container in the task stops or the process that gets started as part of the container entry point exits. The latter typically means that when your application stops, the task stops. Based on your description, if you are launching a new task to do the desired calculation, just have your code exit after completing the calculation.

answered 4 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions