Puts or moves Elastic Compute Service (ECS) instances into or out of the Protected state. After you put an ECS instance into the Protected state, Auto Scaling does not stop or release the ECS instance during a scale-in event. You can only manually delete the ECS instance in the Auto Scaling console or by calling the RemoveInstances operation.
Usage notes
After ECS instances enter the Protected state, they become subject to the following restrictions:
After you put an ECS instance into the Protected state, the instance remains in the Protected state until you move the instance out of the Protected state.
After you put an ECS instance into the Protected state, Auto Scaling does not remove the ECS instance even if a scale-in caused by changes in instance quantity or event-triggered tasks occurs. ECS instances that are in the Protected state can be released only after you manually remove the ECS instances from their respective scaling groups. For more information, see Remove an ECS instance.
ECS instances in the Protected state maintain their health status even when they undergo stopping or restarting processes.
Debugging
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-in events. Valid values:
|
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. |