All Products
Search
Document Center

Auto Scaling:SetInstancesProtection

更新時間:May 17, 2024

Puts Elastic Compute Service (ECS) instances into the Protected state. When ECS instances are put into the Protected state, they become immune to manual deletion attempts by using the Auto Scaling console or API operations. This operation serves as a robust safeguard, efficiently preventing any inadvertent instance release that could lead to irreversible consequences.

Usage notes

Once ECS instances enter the Protected state, they become subject to the following restrictions:

  • ECS instances will persist in the Protected state, unless you deliberately remove them from this state.

  • Even in scenarios where automatic scale-in actions are initiated due to fluctuations in the number of ECS instances or the execution of event-triggered tasks, Auto Scaling does not remove ECS instances that are in the Protected state from their respective scaling groups. Only after being manually removed from their respective scaling groups can ECS instances that are in the Protected state be released. For more information, see Remove an ECS instance.

  • ECS instances in the Protected state maintain their existing health status even when they undergo stopping or restarting processes.

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

SetInstancesProtection

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

ScalingGroupId

String

Yes

asg-bp18p2yfxow2dloq****

The ID of the scaling group.

ProtectedFromScaleIn

Boolean

Yes

true

Specifies whether to protect ECS instances from being stopped or removed from the scaling group during scale-ins. Valid values:

  • true

  • false

InstanceId.N

String

No

i-28wt4****

The ID of ECS instance N. Valid values of N: 1 to 20.

Response parameters

Parameter

Type

Example

Description

RequestId

String

473469C7-AA6F-4DC5-B3DB-A3DC0DE3****

The request ID.

Examples

Sample requests

http(s)://ess.aliyuncs.com/?Action=SetInstancesProtection
&ScalingGroupId=asg-bp18p2yfxow2dloq****
&ProtectedFromScaleIn=true
&InstanceId=["i-28wt4****"]
&<Common request parameters>

Sample success responses

XML format

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

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

JSON format

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

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

Error codes

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

HTTP status code

Error code

Error message

Description

400

IncorrectScalingGroupStatus

The current status of the specified scaling group does not support this action.

The scaling group is not in the Enabled state.

403

Forbidden.Unauthorized

A required authorization for the specified action is not supplied.

You are not authorized to call the SetInstancesProtection operation.

404

InvalidInstanceId.NotFound

Instance “XXX” does not exist.

The specified ECS instance does not exist.

404

InvalidScalingGroupId.NotFound

The specified scaling group does not exist.

The specified scaling group does not exist.