All Products
Search
Document Center

Auto Scaling:DescribeLifecycleActions

Last Updated:Jul 09, 2024

Queries lifecycle hook actions. When you call the DescribeLifecycleActions operation, you can specify parameters such as ScalingActivityId, NextToken, and MaxResults to query the details such as the action status and ID of a lifecycle hook. You can also call this operation to query the IDs of Elastic Compute Service (ECS) instances on which the lifecycle hook takes effect.

Usage notes

Each time scaling activities of the specified type occur in a scaling group, the corresponding lifecycle hooks trigger actions in one of the following states:

  • Pending: When a lifecycle hook action enters this state, ECS instances are pending to be added to or removed from the scaling group.

  • Timeout: When a lifecycle hook action times out, the timeout period of the corresponding lifecycle hook ends, and ECS instances exit the Pending state.

  • Completed: When a lifecycle hook action is complete, ECS instances are manually removed from the Pending state.

If you did not specify DefaultAction when you created a lifecycle hook (for example, you did not specify a CloudOps Orchestration Service (OOS) template to execute after the lifecycle hook times out), you can call this operation to obtain the action token of the lifecycle hook that corresponds to the current scaling activity. Then, you can specify the subsequent action to perform after the lifecycle hook times out.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter

Type

Required

Example

Description

Action

String

Yes

DescribeLifecycleActions

The operation that you want to perform. Set the value to DescribeLifecycleActions.

ScalingActivityId

String

Yes

asa-bp17mug9t0pegagw****

The ID of the scaling activity.

LifecycleActionStatus

String

No

Pending

The status of the lifecycle hook action. Valid values:

  • Pending: The lifecycle hook action is in the Pending state. In this case, ECS instances to which the lifecycle hook applies enter the Pending Add or Pending Remove state.

  • Timeout: The lifecycle hook action times out. In this case, the corresponding lifecycle hook times out, and ECS instances automatically exit the Pending Add or Pending Remove state.

  • Completed: The lifecycle hook action is complete. In this case, ECS instances are manually removed from the Pending Add or Pending Remove state.

NextToken

String

No

AAAAAcSz4VTb1Nq****

The pagination token that is used in the next request to retrieve a new page of results.

For example, after the first 10 lifecycle hook actions were queried, the query starts from the 11th lifecycle hook action. You must specify the token that is obtained from the previous query as the value of NextToken. If you do not specify this parameter, the query starts from the beginning.

MaxResults

Integer

No

10

The maximum number of lifecycle hook actions to return on each page. Valid values: 1 to 50.

Default value: 10.

RegionId

String

No

cn-qingdao

The region ID of the scaling group.

Response parameters

Parameter

Type

Example

Description

NextToken

String

AAAAAcSz4VTb1Nq****

The pagination token that is used in the next request to retrieve a new page of results.

RequestId

String

42A742EB-FCF3-459E-9C62-E107048C17E3

The request ID.

TotalCount

Integer

3

The total number of queried lifecycle hook actions.

MaxResults

Integer

3

The maximum number of lifecycle hook actions returned per page.

LifecycleActions

Array of LifecycleAction

The lifecycle hook actions that correspond to each lifecycle hook.

LifecycleAction

LifecycleHookId

String

ash-bp18uoft0deax0f7****

The ID of the lifecycle hook.

LifecycleActionToken

String

9C2E9DA7-F794-449A-ACF6-CEE24444****

The token of the lifecycle hook action.

LifecycleActionStatus

String

Pending

The status of the lifecycle hook action.

LifecycleActionResult

String

CONTINUE

The action that is performed after the lifecycle hook action is complete. Valid values:

  • CONTINUE: Auto Scaling proceeds to execute either a scale-in or scale-out action as per the request.

  • ABANDON: Auto Scaling releases ECS instances that are created during scale-out events, or removes ECS instances from the scaling group during scale-in events.

InstanceIds

Array of String

["i-bp11m3fzlqrgk5vh****","i-bp11m3fzlqrgk5vh****"]

The IDs of the ECS instances to which the lifecycle hook applies.

Examples

Sample requests

http(s)://ess.aliyuncs.com/?Action=DescribeLifecycleActions
&ScalingActivityId=asa-bp17mug9t0pegagw****
&LifecycleActionStatus=Pending
&NextToken=AAAAAcSz4VTb1Nq****
&MaxResults=10
&RegionId=cn-qingdao
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<DescribeLifecycleActionsResponse>
    <NextToken>AAAAAcSz4VTb1Nq****</NextToken>
    <RequestId>42A742EB-FCF3-459E-9C62-E107048C17E3</RequestId>
    <TotalCount>3</TotalCount>
    <MaxResults>3</MaxResults>
    <LifecycleActions>
        <LifecycleHookId>ash-bp18uoft0deax0f7****</LifecycleHookId>
        <LifecycleActionToken>9C2E9DA7-F794-449A-ACF6-CEE24444F7BB</LifecycleActionToken>
        <LifecycleActionStatus>Pending</LifecycleActionStatus>
        <LifecycleActionResult>CONTINUE</LifecycleActionResult>
        <InstanceIds>["i-bp11m3fzlqrgk5vh****","i-bp11m3fzlqrgk5vh****"]</InstanceIds>
    </LifecycleActions>
</DescribeLifecycleActionsResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "NextToken" : "AAAAAcSz4VTb1Nq****",
  "RequestId" : "42A742EB-FCF3-459E-9C62-E107048C17E3",
  "TotalCount" : 3,
  "MaxResults" : 3,
  "LifecycleActions" : [ {
    "LifecycleHookId" : "ash-bp18uoft0deax0f7****",
    "LifecycleActionToken" : "9C2E9DA7-F794-449A-ACF6-CEE24444F7BB",
    "LifecycleActionStatus" : "Pending",
    "LifecycleActionResult" : "CONTINUE",
    "InstanceIds" : [ "[\"i-bp11m3fzlqrgk5vh****\",\"i-bp11m3fzlqrgk5vh****\"]" ]
  } ]
}

Error codes

For a list of error codes, see Service error codes.

HTTP status code

Error code

Error message

Description

400

InvalidParameter

The specified value of parameter "ScalingActivityId" is not valid.

The value of ScalingActivityId is invalid.

400

InvalidParameter

The specified value of parameter "MaxResults" is not valid.

The value of MaxResults is invalid.

400

InvalidParameter

The specified value of parameter "LifecycleActionStatus" is not valid.

The value of LifecycleActionStatus is invalid.