Lifecycle Hooks pause an Auto Scaling Group action at a specific point — BEFORE an instance is put in service (launch) or BEFORE an instance is terminated — so you can perform custom actions.
| Hook | Triggered When | Common Use |
|---|---|---|
| autoscaling:EC2_INSTANCE_LAUNCHING | New instance just launched, before in-service | Install software, pull config, warm caches, wait for app startup |
| autoscaling:EC2_INSTANCE_TERMINATING | Instance about to terminate | Drain queues, save session data, send final metrics, deregister from service discovery |
Instance Launches
|
v
[Lifecycle Hook: LAUNCHING]
|--- Hook runs (up to 1 hour wait)
|--- Your Lambda/script installs software, warms cache
|--- Lambda calls: aws autoscaling complete-lifecycle-action
v
Instance enters InService state
|--- ALB starts sending traffic
|
... time passes ...
|
Scale-in triggered (too many instances)
|
v
[Lifecycle Hook: TERMINATING]
|--- Hook runs
|--- Lambda drains SQS queue, saves state
|--- Lambda calls: aws autoscaling complete-lifecycle-action
v
Instance terminates
Warm Pools maintain a pool of pre-initialised EC2 instances that are stopped or running (but not receiving traffic). When ASG needs to scale out, it pulls from the warm pool instead of launching fresh instances — dramatically faster scaling.