ALIYUN::ESS::LifecycleHook is used to create a lifecycle hook for a scaling group.
Syntax
{
"Type": "ALIYUN::ESS::LifecycleHook",
"Properties": {
"LifecycleHookName": String,
"NotificationArn": String,
"HeartbeatTimeout": Integer,
"NotificationMetadata": String,
"ScalingGroupId": String,
"DefaultResult": String,
"LifecycleTransition": String
}
}
Properties
Property | Type | Required | Editable | Description | Constraint |
---|---|---|---|---|---|
LifecycleHookName | String | No | Yes | The name of the lifecycle hook. Each name must be unique within a scaling group. | The name must be 2 to 40 characters in length and can contain letters, digits, underscores (_), hyphens (-), and periods (.). It must start with a letter or digit. The default value is the ID of the lifecycle hook. |
NotificationArn | String | No | Yes | The Alibaba Cloud Resource Name (ARN) of the notification receiver that Auto Scaling uses to notify you when an instance is in the transition state for the lifecycle hook. | This receiver can be an OOS template, MNS queue, or MNS topic. Format: acs:ess:{region}:{account-id}:{resource-relative-id} .
Examples:
|
HeartbeatTimeout | Integer | No | Yes | The waiting period before the lifecycle hook times out. When the lifecycle hook times out, the scaling group performs the action specified by the DefaultResult parameter. Unit: seconds. After you create a lifecycle hook, you can call the RecordLifecycleActionHeartbeat operation to extend the timeout period and keep the ECS instance in the wait state. You can also call the CompleteLifecycleAction operation to terminate the wait state of a scaling activity. | Valid values: 30 to 21600. Unit: seconds. Default value: 600. |
NotificationMetadata | String | No | Yes | The fixed string that you want to include when Auto Scaling sends a message about the wait state of a scaling activity to the notification receiver. | The string can be up to 128 characters in length. Auto Scaling sends the specified |
ScalingGroupId | String | Yes | No | The ID of the scaling group. | None |
DefaultResult | String | No | Yes | The action that the scaling group takes when the lifecycle hook times out. If the scaling group has multiple lifecycle hooks and one of them is terminated whenDefaultResult is set to ABANDON during a scale-in event, the remaining lifecycle hooks within the same scaling group are also terminated. Otherwise, the scaling activity proceeds normally after the wait period times out and continues with the action specified by the DefaultResult parameter. |
Default value: CONTINUE. Valid values:
|
LifecycleTransition | String | Yes | Yes | The type of scaling activity to which the lifecycle hook applies. | Valid values:
|
Response parameters
Fn::GetAtt
LifecycleHookId: the ID of the lifecycle hook.
Examples
JSON
format{ "ROSTemplateFormatVersion": "2015-09-01", "Parameters": { "ScalingGroupId": { "Type": "String", "AssociationProperty": "ALIYUN::ESS::AutoScalingGroup::AutoScalingGroupId" } }, "Resources": { "LifecycleHook": { "Type": "ALIYUN::ESS::LifecycleHook", "Properties": { "LifecycleHookName": "Demo997", "NotificationArn": { "Fn::Join": [ "", [ "acs:ess:", { "Ref": "ALIYUN::Region" }, ":", { "Ref": "ALIYUN::TenantId" }, ":", "oos/ACS-ESS-LifeCycleRunCommand" ] ] }, "ScalingGroupId": { "Ref": "ScalingGroupId" }, "LifecycleTransition": "SCALE_OUT", "HeartbeatTimeout": 30, "NotificationMetadata": { "Fn::Join": [ "", [ "{\n \"commandContent\": \"python /home/test.py\",\n \"commandType\": \"RunShellScript\"" ] ] } } } }, "Outputs": { "LifecycleHookId": { "Description": "The lifecycle hook ID", "Value": { "Fn::GetAtt": [ "LifecycleHook", "LifecycleHookId" ] } } } }