Domain name for API request: as.intl.tencentcloudapi.com.
This interface (CreateLifecycleHook) is used for creating a lifecycle hook.
If you configured a notification, Auto Scaling will notify the TDMQ Message Queue of the following information:.
{
"Service": "Tencent Cloud Auto Scaling",
"Time": "2019-03-14T10:15:11Z",
"AppId": "1251783334",
"ActivityId": "asa-fznnvrja",
"AutoScalingGroupId": "asg-ft6y7u8n",
"LifecycleHookId": "ash-p9i7y6t5",
"LifecycleHookName": "my-hook",
"LifecycleActionToken": "3080e1c9-0efe-4dd7-ad3b-90cd6618298f",
"InstanceId": "ins-y6dr5e43",
"LifecycleTransition": "INSTANCE_LAUNCHING",
"NotificationMetadata": ""
}A maximum of 20 requests can be initiated per second for this API.
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 Params. The value used for this API: CreateLifecycleHook. |
| Version | Yes | String | Common Params. The value used for this API: 2018-04-19. |
| Region | Yes | String | Common Params. For more information, please see the list of regions supported by the product. |
| AutoScalingGroupId | Yes | String | Scaling group ID. obtain available scaling group ids in the following ways:. |
| 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 performing the lifecycle hook. valid values:.INSTANCE_LAUNCHING: the lifecycle hook is being scaled out.INSTANCE_TERMINATING: scaling in lifecycle hook |
| DefaultResult | No | String | Action to be taken by the scaling group in case of lifecycle hook timeout or LifecycleCommand execution failure. valid values:. |
| HeartbeatTimeout | No | Integer | The maximum length of time (in seconds) that can elapse before the lifecycle hook times out. Value range: 30-7200. Default value: 300 |
| NotificationMetadata | No | String | Additional information of a notification that auto scaling sends to targets. this parameter is set when you configure a notification (default value: ""), with a maximum length of 1024 characters. NotificationMetadata and LifecycleCommand are mutually exclusive, and either can be specified. |
| NotificationTarget | No | NotificationTarget | Notification target. NotificationTarget and LifecycleCommand cannot be specified at the same time. |
| LifecycleTransitionType | No | String | Specifies the scenario type for performing the lifecycle hook. valid values: NORMAL and EXTENSION. default value: NORMAL.EXTENSION: the lifecycle hook will be triggered when calling AttachInstances, DetachInstances, removeinstances, StopAutoScalingInstances, StartAutoScalingInstances, or StartInstanceRefresh. NORMAL: the lifecycle hook is not triggered by these apis. |
| LifecycleCommand | No | LifecycleCommand | Specifies the remote command execution object. NotificationTarget and NotificationMetadata are mutually exclusive with this parameter. either cannot be specified simultaneously. |
| Parameter Name | Type | Description |
|---|---|---|
| LifecycleHookId | String | Lifecycle hook ID |
| RequestId | String | The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem. |
This example shows you how to create a lifecycle hook that takes effect in the scenario of instance creation, where DefaultResult is set to ABANDON and HeartbeatTimeout is set to 360 seconds.
POST / HTTP/1.1
Host: as.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateLifecycleHook
<Common request parameters>
{
"AutoScalingGroupId": "asg-8fbozqja",
"DefaultResult": "ABANDON",
"LifecycleHookName": "one-hook",
"LifecycleTransition": "INSTANCE_LAUNCHING",
"HeartbeatTimeout": 360
}{
"Response": {
"LifecycleHookId": "ash-heyubibl",
"RequestId": "5e414011-3359-45bd-8ba4-5b503d3fd3f6"
}
}
This example shows you how to create a lifecycle hook that takes effect in the scenario of instance creation, where DefaultResult takes the default value CONTINUE and HeartbeatTimeout takes the default value 300 seconds.
POST / HTTP/1.1
Host: as.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateLifecycleHook
<Common request parameters>
{
"AutoScalingGroupId": "asg-8fbozqja",
"LifecycleHookName": "one-hook-default",
"LifecycleTransition": "INSTANCE_LAUNCHING"
}{
"Response": {
"LifecycleHookId": "ash-8azjzxj9",
"RequestId": "4fa9fd2e-5b6c-49fe-9ba7-ed2ee62d8271"
}
}
This example shows you how to create a lifecycle hook that takes effect in the scenario of instance termination, where DefaultResult is set to ABANDON and HeartbeatTimeout is set to 120 seconds, to notify the TDMQ topic model named one-topic.
POST / HTTP/1.1
Host: as.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateLifecycleHook
<Common request parameters>
{
"HeartbeatTimeout": 120,
"AutoScalingGroupId": "asg-8fbozqja",
"LifecycleHookName": "terminate-topic",
"NotificationMetadata": "topic",
"NotificationTarget": {
"TargetType": "TDMQ_TOPIC",
"TopicName": "one-topic"
},
"DefaultResult": "ABANDON",
"LifecycleTransition": "INSTANCE_TERMINATING"
}{
"Response": {
"LifecycleHookId": "ash-oq76wsrx",
"RequestId": "cdb7670b-0412-444f-9d2f-0da9cd07c410"
}
}
This example shows you how to create a lifecycle hook that takes effect in the scenario of instance creation, where DefaultResult is set to CONTINUE and HeartbeatTimeout is set to 120 seconds, to notify the TDMQ model named one-queue.
POST / HTTP/1.1
Host: as.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateLifecycleHook
<Common request parameters>
{
"HeartbeatTimeout": 120,
"AutoScalingGroupId": "asg-8fbozqja",
"LifecycleHookName": "launch-queue",
"NotificationMetadata": "queue",
"NotificationTarget": {
"TargetType": "TDMQ_QUEUE",
"QueueName": "one-queue"
},
"DefaultResult": "CONTINUE",
"LifecycleTransition": "INSTANCE_LAUNCHING"
}{
"Response": {
"LifecycleHookId": "ash-fbjiexz7",
"RequestId": "d3cf27b7-3090-4317-9107-d2eac986a446"
}
}
This example shows you how to create a lifecycle hook that takes effect in the scenario of instance creation, where DefaultResult takes the default value CONTINUE and HeartbeatTimeout takes the default value 300 seconds.
POST / HTTP/1.1
Host: as.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateLifecycleHook
<Common request parameters>
{
"HeartbeatTimeout": 300,
"AutoScalingGroupId": "asg-mp5ydedh",
"LifecycleCommand": {
"CommandId": "cmd-id9u919l",
"Parameters": "{\"var1\":\"ck\"}"
},
"LifecycleHookName": "demo2",
"DefaultResult": "CONTINUE",
"LifecycleTransition": "INSTANCE_LAUNCHING"
}{
"Response": {
"LifecycleHookId": "ash-kjurq12y",
"RequestId": "08f7bea5-3e0a-4280-9970-5d959a922b0b"
}
}
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. |
| InternalError.CallCmqError | The CMQ API call failed. |
| InternalError.CallTATError | Failed to call the Tencent Automation Tools (TAT) API. |
| InternalError.CalleeError | Exceptions occurred while invoking other services. |
| InvalidParameter | Invalid parameter. |
| InvalidParameter.ActionNotFound | Invalid Action request. |
| 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. |
| InvalidParameterValue.Range | The value is outside the specified range. |
| LimitExceeded.QuotaNotEnough | You are short of the quota. |
| MissingParameter | Parameter missing. |
| ResourceNotFound.AutoScalingGroupNotFound | The scaling group does not exist. |
| ResourceNotFound.CmqQueueNotFound | The specified CMQ queue does not exist. |
| ResourceNotFound.CommandNotFound | The command does not exist. |
| ResourceNotFound.TDMQCMQQueueNotFound | The TDMQ-CMQ queue doesn't exist. |
| ResourceNotFound.TDMQCMQTopicNotFound | The TDMQ-CMQ topic doesn't exist. |
| ResourceUnavailable.CmqTopicHasNoSubscriber | There are no subscribers for the specified CMQ topic. |
| ResourceUnavailable.TDMQCMQTopicHasNoSubscriber | The TDMQ-CMQ topic is not subscribed. |
Feedback