Creates one or more lifecycle hooks for a scaling group.
Operation description
Operation description
-
A scaling group can have a maximum of 6 lifecycle hooks. When a scaling activity occurs in a scaling group that has lifecycle hooks, the lifecycle hooks pause the scaling activity for an epoch. You can specify the wait epoch by using the HeartbeatTimeout parameter. During the wait epoch, you can perform operations such as initialization of ECS instance configurations and retrieving ECS instance data.
-
During a scale-out activity, ECS instances enter the wait state after they are added to the RDS instance whitelist, and are added to the backend server group of the SLB instance after the wait state ends. During a scale-down activity, ECS instances enter the wait state after they are removed from the backend server group of the SLB instance, and are removed from the RDS instance whitelist after the wait state ends.
-
You can configure notification methods for lifecycle hooks. The supported notification methods include MNS topics, MNS queues, and OOS templates. If you configure an OOS template, create a RAM role for the OOS service. For more information, see Settings RAM permissions for OOS.
If the scaling group has existing ECS instances and the configured OOS template is used to add or remove instances from the whitelist of a database other than RDS, you must manually add the existing ECS instances to the whitelist of the 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 within the scaling group. The name must be 2 to 64 characters in length and can contain letters, digits, underscores (_), hyphens (-), and periods (.). The name 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 take after the wait state ends. Valid values:
When a scale-down activity (SCALE_IN) triggers multiple lifecycle hooks in a scaling group, if the DefaultResult of one lifecycle hook is set to ABANDON or ROLLBACK and the wait state of that hook ends, the wait states of the other lifecycle hooks end early. In other cases, the action to take is determined by the last lifecycle hook whose wait state ends. Default value: CONTINUE. |
CONTINUE |
| HeartbeatTimeout |
integer |
No |
The wait period that the lifecycle hook sets for the scaling group activity. After the wait state times out, the next action is performed. Valid values: 30 to 21600. Unit: seconds. After a lifecycle hook is created, you can call RecordLifecycleActionHeartbeat to extend the wait period of an ECS instance, or call CompleteLifecycleAction to end the wait state of a scaling activity early. Default value: 600. |
600 |
| NotificationMetadata |
string |
No |
The notification information that is pushed to NotificationArn (the notification recipient) when the lifecycle hook suspends a scaling activity. This parameter helps you manage and tag notification information of different categories. You must also specify NotificationArn. The value can be up to 4,096 characters in length. If NotificationArn is set to an OOS template, including a public template or a custom template, NotificationMetadata must be set to a JSON string that matches the parameters of the OOS template. For example,
Note
|
Test lifecycle hook. |
| NotificationArn |
string |
No |
The Alibaba Cloud Resource Name (ARN) of the notification recipient of the lifecycle hook. If this parameter is not set, no notification is sent. The following notification methods are supported when you set this parameter:
The variables in the format have the following meanings:
|
acs:mns:cn-beijing:161456884340****:queue/modifyLifecycleHo**** |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| RequestId |
string |
The request ID. |
473469C7-AA6F-4DC5-B3DB-A3DC0DE3**** |
| LifecycleHookId |
string |
The ID of the lifecycle hook. |
ash-bp1at9ufhmcf9cmy**** |
Examples
Success response
JSON format
{
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
"LifecycleHookId": "ash-bp1at9ufhmcf9cmy****"
}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.