As described in the introduction to this chapter, ECS life cycle management refers to the process of taking existing ECS container instances out of service without impacting end users that may be connected to applications running on your affect instances.
This requires you to leverage two key features provided by AWS:
- EC2 Auto Scaling life cycle hooks
- ECS container instance draining
EC2 Auto Scaling life cycle hooks allow you to receive notice of a pending life cycle event and perform some action before the event takes place. Currently, you can be notified of the following life cycle hook events:
EC2_INSTANCE_LAUNCHING
: Raised when an EC2 instance is about to be launchedEC2_INSTANCE_TERMINATING
: Raised when an EC2 instance is about to be terminated
In general, you don't need to worry about EC2_INSTANCE_LAUNCHING
events, however anybody who runs a production-grade ECS cluster should be interested in EC2_INSTANCE_TERMINATING...