You can call this operation to enable or disable protection for one or more ECS instances in a scaling group.

Description

After protection is enabled for an ECS instance:

  • The instance remains in the protected state until you disable protection.
  • The changes in the number of instances in a scaling group and scale-in events triggered by monitoring tasks will not remove ECS instances in the protected state. You must manually Remove an ECS instance to delete an ECS instance that is in the protected state.
  • When an ECS instance is stopped or restarted, its health check status is not updated.

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
InstanceId.N RepeatList Yes i-28wt4****

The IDs of the ECS instances. Valid values of N: 1 to 20.

ProtectedFromScaleIn Boolean Yes true

Specifies whether protection is enabled for an ECS instance. Active protection prevents the ECS instance from being stopped or removed from a scaling group during scale-in events. Valid values:

  • true
  • false
ScalingGroupId String Yes AG6CQdPU8OKdwLjgZcJ****

The ID of the scaling group.

Action String No SetInstancesProtection

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

Response parameters

Parameter Type Example Description
RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

The ID of the request.

Examples

Sample requests


http://ess.aliyuncs.com/?Action=SetInstancesProtection
&ScalingGroupId=AG6CQdPU8OKdwLjgZcJ****
&InstanceId.1=i-28wt4****
&InstanceId.2=i-28wt4****
&ProtectedFromScaleIn=true
&<Common request parameters>

Sample success responses

XML format

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

JSON format

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

Error codes

For more information about error codes, visit API Error Center.

HTTP status code

Error code

Error message

Description

400

IncorrectScalingGroupStatus

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

The error message returned because you have not enabled the specified scaling group.

403

Forbidden.Unauthorized

A required authorization for the specified action is not supplied.

The error message returned because you are not authorized to call the specified operation.

404

InvalidInstanceId.NotFound

Instance "XXX" does not exist.

The error message returned because the specified ECS instance does not exist.

404

InvalidScalingGroupId.NotFound

The specified scaling group does not exist.

The error message returned because the specified scaling group does not exist.