Control instance retention with instance lifecycle policies - Amazon EC2 Auto Scaling

Control instance retention with instance lifecycle policies

Prevent instance termination when lifecycle hooks fail or timeout. Instance lifecycle policies give you control over what happens when termination lifecycle hooks don't complete successfully.

When to use instance lifecycle policies

Use lifecycle policies when you need guaranteed graceful shutdown for:

  • Stateful applications that must complete data persistence before termination

  • Applications requiring extended draining periods (beyond 48 hours)

  • Workloads handling sensitive data that needs proper cleanup

  • Mission-critical services where abrupt shutdown causes availability impact

How instance lifecycle policies work

Instance lifecycle policies control what happens when termination lifecycle hooks fail, timeout, or are abandoned by calling CompleteLifecycleAction. Without a policy, Amazon EC2 Auto Scaling terminates instances immediately when hooks fail. With a retention policy, instances move to a Retained state where they remain until you manually authorize termination.

Retained instances:

  • Continue running as active Amazon EC2 instances

  • Don't count toward your Amazon EC2 Auto Scaling group's desired capacity

  • Incur standard Amazon EC2 charges until terminated

  • Remain in Retained state indefinitely until you take action