Now that you have some background of ECS life cycle management, let's discuss the solution that you will implement in this chapter, which will leverage EC2 life cycle hooks to trigger ECS container instance draining and signal the EC2 Auto Scaling service when it is safe to terminate your ECS container instances.
The following diagram illustrates a simple EC2 Auto Scaling group and an ECS cluster with two ECS container instances in service, supporting ECS Service A and ECS Service B, which both have two ECS tasks or instances of the ECS service running:
Let's ...