You can call RedeployInstance to redeploy an ECS instance when the instance receives an event notification.

Description

RedeployInstance is an asynchronous operation. It migrates data before restarting the instance. After a successful redeployment, the instance enters the running state. After a failed redeployment, the instance returns to the original physical server and is restored to its original state before redeployment. When you call this operation, note that:

  • You can call RedeployInstance when any of the following system events occurs. For more information about system events, see System events.
    • The SystemMaintenance.Reboot and SystemMaintenance.Redeploy events in the scheduled state.
    • The SystemFailure.Reboot event in the executing state (only applicable to instances with local disks).

      Warning When you redeploy an instance with local disks, local disks will be reinitialized and cleared. Use caution when performing this operation.
  • The target instance must be in the running or stopped state. After redeployment, the instance status changes as follows:
    • Instances in the running state enter the stopping state.
    • Instances in the stopped state enter the starting state.
  • An instance cannot be redeployed when the value of its OperationLocks parameter is LockReason: security.
  • An instance on a dedicated host cannot be redeployed.

Debugging

Alibaba Cloud provides OpenAPI Explorer to simplify API usage. You can use OpenAPI Explorer to search for APIs, call APIs, and dynamically generate SDK example code.

Request parameters

Parameter Type Required Example Description
InstanceId String Yes i-bp1azkttqpldxgted****

The ID of the instance that is in the running or stopped state.

Action String No RedeployInstance

The operation that you want to perform. Set this parameter to RedeployInstance. If the request HTTP or HTTPS URL contains different parameters, Action is required.

ForceStop Boolean No false

Specifies whether to force stop the running instance. Default value: false

Note A force stop is equivalent to physical shutdown of the server. This operation can cause data loss if data in the instance is not yet written to the disk. We recommend that you redeploy instances in the stopped state.

Response parameters

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

The ID of the request.

TaskId String t-bp10e8orkp********8x

The ID of the redeployment task. You can call DescribeTasks to view the migration results. The following example shows the required parameters when you call DescribeTasks:

  • Request example:TaskIds=["t-bp10e8or******c74o8x", "t-bp10e8orkpqm0lc74o8y"], TaskAction=RedeployInstance
  • Sample response:
    • TaskStatus=Processing. This state indicates that the instance is being redeployed.
    • TaskStatus=Finished. This state indicates that the instance has been redeployed, and the instance enters the running state.
    • TaskStatus=Failed. This state indicates that the redeployment has failed, and the instance is returned to its original physical server and is restored to its original state before redeployment. If the operation fails, submit a ticket to Alibaba Cloud to obtain technical support.

Examples

Sample requests

https://ecs.aliyuncs.com/?Action=RedeployInstance
&InstanceId=i-bp1azkttqpldxgted****
&<Common request parameters>

Sample success responses

XML format

<RedeployInstanceResponse>
    <RequestId>1C488B66-B819-4D14-8711-C4EAAA13AC01</RequestId>
    <TaskId>t-bp10e8orkp********8x</TaskId>
</RedeployInstanceResponse>

JSON format

{
	"RequestId":"1C488B66-B819-4D14-8711-C4EAAA13AC01",
	"TaskId":"t-bp10e8orkp********8x"
}

Error codes

HTTP status code Error code Error message Description
404 InvalidInstanceId.NotFound The InstanceId provided does not exist in our records. The error message returned because the specified instance does not exist.
403 IncorrectInstanceStatus The current status of the resource does not support this operation. The error message returned because the operation is not supported while the resource is in the current state.
403 InstanceLockedForSecurity The specified operation is denied as your instance is locked for security reasons. The error message returned because the operation is not supported while the instance is locked for security reasons.
403 DiskError IncorrectDiskStatus. The error message returned because the specified disk status is invalid.
500 InternalError The request processing has failed due to some unknown error. The error message returned because an internal error has occurred. Try again later. If the problem persists, submit a ticket.
403 InstanceExpiredOrInArrears The specified operation is denied as your prepay instance is expired (prepay mode) or in arrears (afterpay mode). The error message returned because the subscription instance has expired. Renew the instance and try again.
403 IncorrectInstanceStatus %s The error message returned because the operation is not supported while the instance is in the current state.

View error codes