Changes the deployment set of an Elastic Compute Service (ECS) instance or migrates an ECS instance to a dedicated host. You can change the instance type of the ECS instance when you migrate the instance.
Description
When you call this operation for an ECS instance, take note of the following items:
- The ECS instance must be in the Stopped state. The instance is automatically restarted after it is migrated.
- The network type of the ECS instance must be Virtual Private Cloud (VPC).
- The ECS instance and the destination dedicated host to which to migrate the instance must belong to the same account and reside in the same region and zone.
- A pay-as-you-go ECS instance can be migrated to a subscription dedicated host. A subscription ECS instance can be migrated only between subscription dedicated hosts. The expiration date of the subscription ECS instance cannot be later than that of the destination dedicated host.
- You can migrate only pay-as-you-go ECS instances from a shared host to a dedicated host. You cannot migrate subscription or preemptible instances from a shared host to a dedicated host.
- You can redeploy an ECS instance to a specific dedicated host cluster.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | ModifyInstanceDeployment | The operation that you want to perform. Set the value to ModifyInstanceDeployment. |
RegionId | String | Yes | cn-hangzhou | The region ID of the instance. You can call the DescribeRegions operation to query the most recent region list. |
InstanceId | String | Yes | i-bp67acfmxazb4ph*** | The IDs of instances. |
DedicatedHostId | String | No | dh-bp67acfmxazb4ph**** | The ID of the destination dedicated host. You can call the DescribeDedicatedHosts operation to query the most recent list of dedicated hosts. When you migrate an instance from a shared host to a dedicated host or between dedicated hosts, take note of the following items:
For information about the automatic deployment feature, see Features of dedicated hosts. |
DeploymentSetId | String | No | ds-bp67acfmxazb4ph**** | The ID of the destination deployment set. This parameter is required when you add an ECS instance to a deployment set or change the deployment set of an instance. Note You cannot change the deployment set when you modify the configurations of dedicated hosts, including parameters such as Tenancy , Affinity , and DedicatedHostId . |
DeploymentSetGroupNo | Integer | No | 3 | The number of the deployment set group in which to deploy the instance in the destination deployment set. This parameter is valid only when the destination deployment set uses the high availability group strategy (AvailabilityGroup). Valid values: 1 to 7. Note If you call this operation to deploy an instance to a deployment set that uses the high availability group strategy ( AvailabilityGroup ) and this parameter is left empty, the system evenly distributes ECS instances among the deployment set groups in the deployment set. If you call this operation to change the deployment set of an instance and specify the current deployment set of the instance as the destination deployment set, the system evenly distributes ECS instances again among the deployment set groups in the deployment set. |
Force | Boolean | No | false | Specifies whether to forcibly change the host of the instance when the deployment set of the instance is changed. Valid values:
Default value: false. |
Affinity | String | No | host | Specifies whether to associate the instance with a dedicated host. Valid values:
If you want to migrate the instance from a shared host to a dedicated host, use the default value. Default value: default. |
Tenancy | String | No | host | Specifies whether to deploy the instance on a dedicated host. Set the value to host to deploy the instance on a dedicated host. |
MigrationType | String | No | live | Specifies whether to stop the instance before it is migrated to the destination dedicated host. Valid values:
Default value: reboot. |
InstanceType | String | No | ecs.c6.large | The instance type to which the instance is changed. You can call the DescribeInstanceTypes operation to query the most recent list of instance types. You can change the instance type of the ECS instance when you migrate the instance to a dedicated host. The new instance type must match the type of the specified dedicated host. For more information, see Dedicated host types.
|
DedicatedHostClusterId | String | No | dc-bp67acfmxazb4ph**** | The ID of the dedicated host cluster. |
RemoveFromDeploymentSet | Boolean | No | false | Specifies whether to remove the selected instance from the selected deployment set. Valid values:
Default value: false. Note If you set this parameter to true, you must specify the InstanceId of the selected ECS instance and DeploymentSetId of the deployment set to which the ECS instance belongs. |
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
RequestId | String | 04F0F334-1335-436C-A1D7-6C044FE7**** | The ID of the request. |
Examples
Sample requests
http(s)://ecs.aliyuncs.com/?Action=ModifyInstanceDeployment
&RegionId=cn-hangzhou
&InstanceId=i-bp67acfmxazb4ph***
&DedicatedHostId=dh-bp67acfmxazb4ph****
&DeploymentSetId=ds-bp67acfmxazb4ph****
&Tenancy=host
&MigrationType=live
&DedicatedHostClusterId=dc-bp67acfmxazb4ph****
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<ModifyInstanceDeploymentResponse>
<RequestId>04F0F334-1335-436C-A1D7-6C044FE7****</RequestId>
</ModifyInstanceDeploymentResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "04F0F334-1335-436C-A1D7-6C044FE7****"
}
Error codes
HttpCode | Error code | Error message | Description |
---|---|---|---|
400 | OperationDenied.UnstoppedInstance | Operation denied due to unstopped instance. | The error message returned because the current operation is invalid. Check whether the instance is in the Stopped state. |
400 | InvalidDedicatedHostStatus.NotSupport | Operation denied due to dedicated host status. | The error message returned because the operation is not supported while the dedicated host is in the current state. |
400 | InvalidPeriod.ExceededDedicatedHost | Instance expired date can't exceed dedicated host expired date. | The error message returned because the expiration date of the instance is later than that of the dedicated host. |
400 | InvalidParam.Tenancy | The specified Tenancy is invalid. | The error message returned because the specified Tenancy parameter is invalid. |
400 | OperationDenied.InvalidInstance | The specified instance is not dedicated instance. | The error message returned because the specified instance is not deployed on a dedicated host. |
400 | ChargeTypeViolation.PostPaidDedicatedHost | Prepaid instance onto postpaid dedicated host is not allowed. | The error message returned because subscription instances cannot be deployed on pay-as-you-go dedicated hosts. |
400 | InvalidDedicatedHostId.NotFound | The specified DedicatedHostId does not exist. | The error message returned because the specified DedicatedHostId parameter does not exist. |
400 | InvalidInstanceType.ValueNotSupported | The specified InstanceType does not exist or beyond the permitted range. | The error message returned because the specified InstanceType parameter does not exist or because you are not authorized to manage instances of the specified instance type. |
403 | IncorrectInstanceStatus | %s | The error message returned because the operation is not supported while the instance is in the current state. |
403 | OperationDenied.NoStock | The resource is out of usage. | The error message returned because the instance is not in the Running state. Start the instance or check whether the operation is valid. |
404 | InvalidInstanceId.NotFound | The specified InstanceId does not exist. | The error message returned because the specified instance ID does not exist. Check whether the instance ID is correct. |
404 | InvalidInstanceNetworkType.NotSupport | The specified Instance network type not support. | The error message returned because the network type of the instance does not support this operation. |
404 | InvalidInstanceType.NotSupport | The Dedicated host not support the specified instance type. | The error message returned because the current dedicated host does not support the specified instance type. |
For a list of error codes, visit the API Error Center.