In this code provided with the blog, we will demonstrate how to use the draining state to update the AMI used by EC2 instances in your cluster by updating the launch configuration of your auto-scaling group. The process also ensures that the EC2 instances get the tasks drained the tasks launch on new container instance before termination occurs.
This code is only an example that doesn't seem to be maintained as well.
We at GetSocial wrote production-ready (we are using it in production for years) and more feature rich (spot instances draining) version: https://github.com/getsocial-rnd/ecs-drain-lambda
What do you think about archiving this repo and creating a link to our tool? Thanks!