Modifies a lifecycle hook.

Usage notes

You can use one of the following methods to specify the lifecycle hook that you want to modify:

  • Specify the lifecycle hook ID by using LifecycleHookId. When you use this method, ScalingGroupId and LifecycleHookName are ignored.
  • Specify the scaling group ID by using ScalingGroupId and specify the lifecycle hook name by using LifecycleHookName.

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

ParameterTypeRequiredExampleDescription
ActionStringYesModifyLifecycleHook

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

LifecycleHookIdStringNoash-bp1fxuqyi98w0aib****

The ID of the lifecycle hook that you want to modify.

ScalingGroupIdStringNoasg-bp18p2yfxow2dloq****

The ID of the scaling group to which the lifecycle hook belongs.

LifecycleHookNameStringNotest_SCALE_IN

The name of the lifecycle hook that you want to modify.

DefaultResultStringNoCONTINUE

The action that Auto Scaling performs after the lifecycle hook of the scaling group times out. Valid values:

  • CONTINUE: Auto Scaling continues to respond to a scale-in or scale-out request.
  • ABANDON: Auto Scaling releases Elastic Compute Service (ECS) instances that are created during scale-outs, or removes ECS instances from the scaling group during scale-ins.
  • ROLLBACK: For scale-ins, Auto Scaling rejects the requests to release ECS instances but rolls back ECS instances. For scale-outs, the ROLLBACK setting has the same effect as the ABANDON setting.

If a scaling group has multiple lifecycle hooks in effect and you set DefaultResult for one of the lifecycle hooks to ABANDON or ROLLBACK, the following rule applies to scale-ins: When the lifecycle hook whose DefaultResult is set to ABANDON or ROLLBACK times out, other lifecycle hooks time out ahead of schedule. In other cases, Auto Scaling performs the action only after all lifecycle hooks time out. The action that Auto Scaling performs is determined by the value of DefaultResult that you specify for the lifecycle hook that most recent times out.

HeartbeatTimeoutIntegerNo600

The timeout period of the lifecycle hook. When the lifecycle hook times out, Auto Scaling performs the action that is specified by DefaultResult. Valid values: 30 to 21600. Unit: seconds.

You can call the RecordLifecycleActionHeartbeat operation to extend the timeout period of a lifecycle hook. You can also call the CompleteLifecycleAction operation to end the timeout period of a lifecycle hook ahead of schedule.

LifecycleTransitionStringNoSCALE_IN

The type of scaling activities to which you want to apply the lifecycle hook. Valid values:

  • SCALE_OUT
  • SCALE_IN
NotificationMetadataStringNoTest

The fixed string that is included in a notification which indicates that the lifecycle hook takes effect. The value of this parameter cannot exceed 4,096 characters in length.

Auto Scaling sends the value of NotificationMetadata together with the notification. This helps you categorize your notifications. If you specify NotificationMetadata, you must specify NotificationArn.

NotificationArnStringNoacs:mns:cn-beijing:161456884340****:queue/modifyLifecycleHo****

The Alibaba Cloud Resource Name (ARN) of the notification method. The following list describes the value formats of this parameter:

  • If you use a Message Service (MNS) queue as the notification method, specify the value in the acs:mns:{region-id}:{account-id}:queue/{queuename} format.
  • If you use an MNS topic as the notification method, specify the value in the acs:mns:{region-id}:{account-id}:topic/{topicname} format.
  • If you use an Operation Orchestration Service (OOS) template as the notification method, specify the value in the acs:oos:{region-id}:{account-id}:template/{templatename} format.
  • If you use an event bus provided by EventBridge as the notification method, specify the value in the acs:eventbridge:{region-id}:{account-id}:eventbus/default format.

The variables in the preceding value formats have the following meanings:

  • region-id: the region ID of the scaling group.
  • account-id: the ID of the Alibaba Cloud account.
  • queuename: the name of the MNS queue.
  • topicname: the name of the MNS topic.
  • templatename: the name of the OOS template.
RegionIdStringNocn-beijing

The region ID of the scaling group.

LifecycleHookStatusStringNoActive

The status that you want to specify for the lifecycle hook. Valid values: Valid values:

  • Active
  • InActive

If you do not specify this parameter, the status of the lifecycle hook remains unchanged after you call this operation.

Note By default, a new lifecycle hook is in the Active state.

Response parameters

ParameterTypeExampleDescription
RequestIdString473469C7-AA6F-4DC5-B3DB-A3DC0DE3****

The ID of the request.

Examples

Sample requests

http(s)://ess.aliyuncs.com/?Action=ModifyLifecycleHook
&LifecycleHookId=ash-bp1fxuqyi98w0aib****
&ScalingGroupId=asg-bp18p2yfxow2dloq****
&LifecycleHookName=test_SCALE_IN
&DefaultResult=CONTINUE
&HeartbeatTimeout=600
&LifecycleTransition=SCALE_IN
&NotificationMetadata=Test
&NotificationArn=acs:mns:cn-beijing:161456884340****:queue/modifyLifecycleHo****
&RegionId=cn-beijing
&LifecycleHookStatus=Active
&<Common request parameters>

Sample success responses

XML format

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

<ModifyLifecycleHookResponse>
    <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3****</RequestId>
</ModifyLifecycleHookResponse>

JSON format

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

{
  "RequestId" : "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****"
}

HTTP status code

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

HTTP status code

Error code

Error message

Description

400

InvalidParamter

The specified value of parameter is not valid.

The value of a parameter is invalid.

400

InvalidLifecycleHookId.NotExist

The specified lifecycleHookId not exist.

The value of LifecycleHookId is invalid.

400

InvalidLifecycleHookName.NotExist

The specified lifecycleHookName you provided not exist.

The value of LifecycleHookName is invalid.

400

InvalidNotificationArn

The specified parameter NotificationArn is invalid.

The value of NotificationArn is invalid.

400

UnsupportedNotificationType.CurrentRegion

The NotificationType is not supported in the special region which scalingGroup belongs to.

The notification type is not supported in the region where the scaling group resides.

400

LifecycleHook

The specified queue does not exist.

The MNS queue does not exist.

400

TopicNotExist

The specified topic does not exist.

The MNS topic does not exist.