Reputation: 1
Problem: Fargate tasks are being shut down without completing the processes within the task upon scaling in. (Auto Scaling implemented)
Is there a possibility for the Fargate task to exit gracefully (to complete all the processes within the task before shutting it down)?
There is a way in EC2 to handle this through Life cycle hooks but I'm not sure if there is anything similar in the Amazon Fargate cluster.
Upvotes: 0
Views: 5926
Reputation: 41
In 2022 AWS introduced the Task scale-in protection endpoint.
The following task scale-in protection endpoint path is available to containers: $ECS_AGENT_URI/task-protection/v1/state
Upvotes: 3
Reputation: 961
Capture the SIGTERM
signal and do your cleanup in there. You can trap it in your application, using whatever programming language that you want, or trap it in a shell entrypoint script.
For more information see this blogpost from AWS.
Upvotes: 1