# Lifecycle Hooks

* Lifecycle hooks **enable you to perform custom actions by pausing instances as an Auto Scaling group launches or terminates them**.<br>

* **When an instance is paused, it remains in a wait state either until you complete the lifecycle action** using the complete-lifecycle-action command or the `CompleteLifecycleAction` operation, or until the timeout period ends (one hour by default).

* For example, your **newly launched instance completes its startup sequence and a lifecycle hook pauses the instance**.

  * **While the instance is in a wait state, you can install or configure software on it**, making sure that your instance is fully ready before it starts receiving traffic.

* For another example of the use of lifecycle hooks, **when a scale-in event occurs, the terminating instance is first deregistered from the load balancer** (if the Auto Scaling group is being used with Elastic Load Balancing).
  * Then, a **lifecycle hook pauses the instance before it is terminated**.
  * **While the instance is in the wait state, you can, for example, connect to the instance and download logs or other data before the instance is fully terminated**.<br>

* This shows the transitions between instance states in this process:

![](https://4079160698-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MOmHH1M7R1RV5MGm4F7%2F-MOrD4pjVYdLdKIFoI8n%2F-MOrMkcdXrjKaV5ylH6v%2Fimage.png?alt=media\&token=c0b15769-d6e3-4ce3-8b7c-cff7395c0e27)
