Domain name for API request: as.tencentcloudapi.com.
This API (CreateLifeCycleHook) is used to create a lifecycle hook.
{
"Service": "Tencent Cloud Auto Scaling",
"Time": "2019-03-14T10:15:11Z",
"AppId": "1251783334",
"ActivityId": "asa-fznnvrja",
"AutoScalingGroupId": "asg-rrrrtttt",
"LifecycleHookId": "ash-xxxxyyyy",
"LifecycleHookName": "my-hook",
"LifecycleActionToken": "3080e1c9-0efe-4dd7-ad3b-90cd6618298f",
"InstanceId": "ins-aaaabbbb",
"LifecycleTransition": "INSTANCE_LAUNCHING",
"NotificationMetadata": ""
}
A maximum of 20 requests can be initiated per second for this API.
Note: This API supports Finance regions. If the common parameter Region is a Finance region, a domain name with the Finance region needs to be specified, for example: as.ap-shanghai-fsi.tencentcloudapi.com
The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.
Parameter Name | Required | Type | Description |
---|---|---|---|
Action | Yes | String | Common parameter. The value used for this API: CreateLifecycleHook. |
Version | Yes | String | Common parameter. The value used for this API: 2018-04-19. |
Region | Yes | String | Common parameter. For more information, please see the list of regions supported by the product. |
AutoScalingGroupId | Yes | String | Auto scaling group ID |
LifecycleHookName | Yes | String | Lifecycle hook name, which can contain Chinese characters, letters, numbers, underscores (_), hyphens (-), and periods (.) with a maximum length of 128 bytes. |
LifecycleTransition | Yes | String | Scenario for the lifecycle hook. Valid values: "INSTANCE_LAUNCHING" and "INSTANCE_TERMINATING" |
DefaultResult | No | String | Defined actions when lifecycle hook times out. Valid values: "CONTINUE" and "ABANDON". Default value: "CONTINUE" |
HeartbeatTimeout | No | Integer | The maximum length of time (in seconds) that can elapse before the lifecycle hook times out. Value range: 30-3,600. Default value: 300 |
NotificationMetadata | No | String | Additional information of a notification that Auto Scaling sends to targets. This parameter is left empty by default. Up to 1024 characters are allowed. |
NotificationTarget | No | NotificationTarget | Notification target |
LifecycleTransitionType | No | String | The scenario where the lifecycle hook is applied. EXTENSION : the lifecycle hook will be triggered when AttachInstances, DetachInstances or RemoveInstaces is called. NORMAL : the lifecycle hook is not triggered by the above APIs. |
Parameter Name | Type | Description |
---|---|---|
LifecycleHookId | String | Lifecycle hook ID |
RequestId | String | The unique request ID, which is returned for each request. RequestId is required for locating a problem. |
This example shows you how to create a lifecycle hook that takes effect upon instance creation, where DefaultResult
takes the default value CONTINUE
and HeartbeatTimeout
takes the default value 300 seconds.
https://as.tencentcloudapi.com/?Action=CreateLifecycleHook
&AutoScalingGroupId=asg-8fbozqja
&LifecycleHookName=one-hook-default
&LifecycleTransition=INSTANCE_LAUNCHING
&<Common request parameters>
{
"Response": {
"LifecycleHookId": "ash-8azjzxj9",
"RequestId": "4fa9fd2e-5b6c-49fe-9ba7-ed2ee62d8271"
}
}
This example shows you how to create a lifecycle hook that takes effect upon instance creation, where DefaultResult
is set to ABANDON and HeartbeatTimeout
is set to 360 seconds.
https://as.tencentcloudapi.com/?Action=CreateLifecycleHook
&AutoScalingGroupId=asg-8fbozqja
&DefaultResult=ABANDON
&HeartbeatTimeout=360
&LifecycleHookName=one-hook
&LifecycleTransition=INSTANCE_LAUNCHING
&<Common request parameters>
{
"Response": {
"LifecycleHookId": "ash-heyubibl",
"RequestId": "5e414011-3359-45bd-8ba4-5b503d3fd3f6"
}
}
This example shows you how to create a lifecycle hook that takes effect upon instance creation, where DefaultResult
is set to CONTINUE and HeartbeatTimeout
is set to 120 seconds to notify the CMQ queuing model named "one-queue".
https://as.tencentcloudapi.com/?Action=CreateLifecycleHook
&AutoScalingGroupId=asg-8fbozqja
&DefaultResult=CONTINUE
&HeartbeatTimeout=120
&LifecycleHookName=launch-queue
&LifecycleTransition=INSTANCE_LAUNCHING
&NotificationMetadata=queue
&NotificationTarget.TargetType=CMQ_QUEUE
&NotificationTarget.QueueName=one-queue
&<Common request parameters>
{
"Response": {
"LifecycleHookId": "ash-fbjiexz7",
"RequestId": "d3cf27b7-3090-4317-9107-d2eac986a446"
}
}
This example shows you how to create a lifecycle hook that takes effect upon instance termination, where DefaultResult
is set to ABANDON
and HeartbeatTimeout
is set to 120 seconds to notify the CMQ topic named one-topic
.
https://as.tencentcloudapi.com/?Action=CreateLifecycleHook
&AutoScalingGroupId=asg-8fbozqja
&DefaultResult=ABANDON
&HeartbeatTimeout=120
&LifecycleHookName=terminate-topic
&LifecycleTransition=INSTANCE_TERMINATING
&NotificationMetadata=topic
&NotificationTarget.TargetType=CMQ_TOPIC
&NotificationTarget.TopicName=one-topic
&<Common request parameters>
{
"Response": {
"LifecycleHookId": "ash-oq76wsrx",
"RequestId": "cdb7670b-0412-444f-9d2f-0da9cd07c410"
}
}
TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.
The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.
Error Code | Description |
---|---|
InternalError | An internal error occurred. |
InvalidParameter | Invalid parameter. |
InvalidParameter.Conflict | Multiple parameters specified conflict and cannot co-exist. |
InvalidParameterValue | Wrong parameter value. |
InvalidParameterValue.Filter | Invalid filter. |
InvalidParameterValue.InvalidAutoScalingGroupId | Invalid scaling group ID. |
InvalidParameterValue.LifecycleHookNameDuplicated | The lifecycle hook name already exists. |
LimitExceeded.QuotaNotEnough | You are short of the quota. |
MissingParameter | Parameter missing. |
ResourceNotFound.AutoScalingGroupNotFound | The scaling group does not exist. |
Was this page helpful?