Lifecycle hooks pause scaling activities and hand control to CloudOps Orchestration Service (OOS), which runs the operations and maintenance (O&M) tasks defined in an OOS template before the activity resumes. Use this pattern to automate instance preparation during scale-out events (for example, binding secondary Elastic Network Interfaces (ENIs) or updating database whitelists) and instance cleanup during scale-in events (for example, copying logs or clearing data).
How it works
When a scaling activity is triggered, Auto Scaling suspends the activity and puts the affected ECS instances into the Pending:Wait state. OOS then runs the O&M operations specified in the template. After OOS finishes, the instances leave Pending:Wait and the scaling activity either continues or ends based on the result.

The outcome depends on whether the O&M operations succeed:
If the operations succeed, the scaling activity continues:
Scale-out: ECS instances are added to the scaling group.
Scale-in: ECS instances are removed from the scaling group.
If the operations fail, the scaling activity ends:
Scale-out: ECS instances are released.
Scale-in: ECS instances are still removed from the scaling group. The scale-in event is not affected by the failure.
A failed O&M operation does not protect instances from scale-in. If the goal is to preserve data before termination, ensure the OOS template handles data preservation tasks.
Why use OOS templates
OOS templates offer several advantages over custom notification handlers:
Composable O&M workflows: Templates define task sequences, execution order, and input/output parameters, making it straightforward to implement multi-step O&M processes.
Automatic triggering: Lifecycle hook notifications invoke OOS directly — no custom code needed to parse notification payloads.
Ready-to-use public templates: Alibaba Cloud provides public templates for common tasks. See .
Custom templates: Build your own templates for scenarios not covered by public templates. See .
For more information about OOS, see .
Available public templates
The following public templates cover the most common O&M tasks for lifecycle hooks. Each template name maps directly to the OOS public template catalog.
| Template | Applicable event | Description | Guide |
|---|---|---|---|
| ACS-ESS-LifeCycleApplyAutoSnapshotPolicy | Scale-out | Apply automatic snapshot policies to disks. | Apply an automatic snapshot policy to ECS instances |
| ACS-ESS-LifeCycleRunCommand | Scale-out and scale-in | Run commands on ECS instances. | Automatically execute scripts on ECS instances |
| ACS-ESS-LifeCycleModifyPolarDBIPWhitelist | Scale-out and scale-in | Update the IP address whitelist of PolarDB clusters. | Automatically add or remove ECS instance IP addresses from a PolarDB cluster whitelist |
| ACS-ESS-LifeCycleModifyRedisIPWhitelist | Scale-out and scale-in | Update the IP address whitelist of ApsaraDB for Redis instances. | Automatically add or remove ECS instance IP addresses from an ApsaraDB for Redis whitelist |
| ACS-ESS-LifeCycleModifyMongoDBIPWhitelist | Scale-out and scale-in | Update the IP address whitelist of ApsaraDB for MongoDB instances. | Automatically add or remove ECS instance IP addresses from a MongoDB instance whitelist |
| ACS-ESS-LifeCycleModifyAnalyticDBIPWhitelist | Scale-out and scale-in | Update the IP address whitelist of AnalyticDB for MySQL clusters. | Automatically add or remove ECS instance IP addresses from an AnalyticDB for MySQL cluster whitelist |
| ACS-ESS-LifeCycleAttachNASFileSystemToInstance | Scale-out | Mount NAS file systems to ECS instances. | Mount NAS file systems to ECS instances |
| ACS-ESS-LifeCycleCreateNetworkInterfaceAndEipAndAttachToInstance | Scale-out | Create secondary ENIs and Elastic IP Addresses (EIPs), associate each EIP with a secondary ENI, and bind the ENIs to ECS instances. | Automatically bind secondary ENIs to ECS instances |
| ACS-ESS-LifeCycleDetachNetworkInterfaceAndDeleteEip | Scale-in | Unbind secondary ENIs from ECS instances, then release the ENIs and their associated EIPs. | Automatically unbind secondary ENIs from ECS instances |
| ACS-ESS-LifeCycleAllocateEipAddressAndAttachToInstance | Scale-out | Create EIPs and associate them with ECS instances. | Automatically associate EIPs with ECS instances |
| ACS-ESS-LifeCycleReleaseEipAddressFromInstance | Scale-in | Disassociate EIPs from ECS instances and release them. | Enable the automatic release feature for an EIP |
What's next
Learn about ECS instance state transitions during scaling activities: Instance lifecycles
Browse all OOS public templates:
Build a template for your own requirements: