You need to enable JavaScript to run this app.
Auto Scaling

Auto Scaling

Copy page
Download PDF
Lifecycle hook
Creating lifecycle hooks
Copy page
Download PDF
Creating lifecycle hooks
Scenarios​
This topic describes how to create a lifecycle hook used to suspend target instances in a scaling group during automatic scaling operations, enabling you to perform required custom actions.​
Procedure​
  1. Log in to the Scaling Group console. ​
  1. In the top menu bar, select the project and region of the target resource.​
  1. Click the name of the scaling group and select the "Lifecycle hook" tab.​
  1. Click the "Create Lifecycle Hook" button and configure the parameters based on the table below.​
  • ​
    Parameter​​
    Description​
    Sample value​
    Name​
    The name of the lifecycle hook. Name changes are not supported after the lifecycle hook is created.​
    we01​
    Scaling Rule Type​
    Lifecycle hooks are triggered when scaling groups automatically perform scale-in and scale-out operations.​
    Scale-in Event​
    Timeout​
    The duration an instance remains in the suspended status. After the hook times out, the suspended status ends automatically, and the scaling operations continue based on the execution policy.​
    After you evaluate the execution time of your custom actions, set an appropriate timeout period. Value range: 30 seconds to 21600 seconds (6 hours).​
    1800s​
    Execution Policy​
    Select the operation to be performed after an instance exits from the suspended state. Supported options include "Continue", "Reject", and "Roll back". For a detailed introduction to the instance-targeted process after execution, refer to Execution processes and policies.​
    Continue​
    The action of associating a hook​
    Configure whether to perform custom operations on multiple instances in the suspended status via Cloud assistant. With Cloud assistant enabled, O&M commands can be easily executed, which applies to scenarios where instances need to be added or removed in batches.​
    Cloud assistant​
    Parameter​​
    This parameter needs to be configured only when the action of associating a hook is "Cloud assistant". Select the required Cloud assistant command and enter values for the command parameters.​
    tip​
    The operation duration of Cloud assistant depends on the command you select. We recommend setting the hook timeout period longer than the command execution time. Otherwise, the lifecycle hook may time out before the command execution completes, which may impact your business.​
    --​
    ​
  1. Click "Confirm" to complete the operation.​
Operation result​
After the lifecycle hook is triggered for a scaling group, select the "Instance Management" tab. Then, you can see that the corresponding instance changes to the "Adding/removal suspended" status. At this point, you can log in to the instance to perform custom operations.​
When Cloud assistant is enabled for command execution, you can view the command execution result in the ECS console. For details, refer to Viewing job execution results.​
  • If the command is executed before the lifecycle hook times out, the suspended status of instances ends immediately, and the scaling operation continues based on the "Continue" policy.​
  • If the command execution times out or fails before the lifecycle hook times out, the suspended status of instances ends immediately, and the scaling operation continues based on the execution policy of the lifecycle hook.​
Related document​
​
Last updated: 2026.06.24 17:08:50