CreateLifecycleHook
Creates one or more lifecycle hooks for a scaling group.
Operation description
Operation description
-
You can create up to six lifecycle hooks for a scaling group. When a scaling activity occurs in a scaling group that has lifecycle hooks, the lifecycle hooks pause the scaling activity for a specified period. You can specify the wait time by using the HeartbeatTimeout parameter. During the wait time, you can perform operations such as initialization of ECS instance configurations and obtaining ECS instance data.
-
During a scale-out activity, ECS instances enter the wait state after they are added to the whitelist of an ApsaraDB RDS instance. After the wait state ends, the ECS instances are added to the backend server group of a Server Load Balancer (SLB) instance. During a scale-in activity, ECS instances enter the wait state after they are removed from the backend server group of the SLB instance. After the wait state ends, the ECS instances are removed from the whitelist of the ApsaraDB RDS instance.
-
You can configure notification methods for lifecycle hooks. Supported notification methods include Message Service (MNS) topics, MNS queues, and Operation Orchestration Service (OOS) templates. If you configure an OOS template, you must create a Resource Access Management (RAM) role for OOS. For more information, see RAM permission Settings for OOS.
If the scaling group contains existing ECS instances and the configured OOS template is used to add or remove the instances from the whitelist of a cloud database other than ApsaraDB RDS, you must manually add the existing ECS instances to the whitelist of the cloud database.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
ess:CreateLifecycleHook |
create |
*ScalingGroup
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| ScalingGroupId |
string |
Yes |
The ID of the scaling group. |
asg-bp1eyv4qn8ssgv43**** |
| LifecycleHookName |
string |
No |
The name of the lifecycle hook. The name must be unique among the lifecycle hooks in the scaling group. The name must be 2 to 64 characters in length and can contain letters, digits, underscores (_), hyphens (-), and periods (.). It must start with a letter, digit, or Chinese character. Default value: the value of LifecycleHookId. |
lifecyclehook**** |
| LifecycleTransition |
string |
Yes |
The type of scaling activity to which the lifecycle hook applies. Valid values:
|
SCALE_OUT |
| DefaultResult |
string |
No |
The action to perform after the wait state ends. Valid values:
When a scale-in activity (SCALE_IN) occurs in the scaling group and multiple lifecycle hooks are triggered, if the Default value: CONTINUE. |
CONTINUE |
| HeartbeatTimeout |
integer |
No |
The wait time set by the lifecycle hook for the scaling activity. After the wait time expires, the next action is performed. Valid values: 30 to 21600. Unit: seconds. After you create a lifecycle hook, you can call the RecordLifecycleActionHeartbeat operation to extend the wait time of the ECS instance, or call the CompleteLifecycleAction operation to end the wait state of the scaling activity in advance. Default value: 600. |
600 |
| NotificationMetadata |
string |
No |
The notification message pushed to the If For example,
Note
|
Test lifecycle hook. |
| NotificationArn |
string |
No |
The identity of the Notification Recipient for the lifecycle hook. If you do not configure Settings for this parameter, no notifications are sent. If you configure Settings for this parameter, the following notification methods are supported:
The variables in the formats have the following meanings:
|
acs:mns:cn-beijing:161456884340****:queue/modifyLifecycleHo**** |
| LifecycleActionSources |
array |
No |
The specific scenarios that trigger the lifecycle hook. |
|
|
string |
No |
The specific scenarios that trigger the lifecycle hook. Valid values when LifecycleTransition is set to SCALE_OUT:
Default value: Valid values when LifecycleTransition is set to SCALE_IN:
Default value: |
DirectToScalingGroup |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| LifecycleHookId |
string |
The ID of the lifecycle hook. |
ash-bp1at9ufhmcf9cmy**** |
| RequestId |
string |
The request ID. |
473469C7-AA6F-4DC5-B3DB-A3DC0DE3**** |
Examples
Success response
JSON format
{
"LifecycleHookId": "ash-bp1at9ufhmcf9cmy****",
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****"
}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.