Modifies the VPC attributes of an ECS instance.

Description

When you call this operation, note that:

  • You can only modify the VPC attributes of an ECS instance which is in the stopped (Stopped) state.
  • A new ECS instance must have been started and stopped before you call this operation.
  • An ECS instance that has the VPC attributes modified must have been started and stopped before you call this operation.
  • If VSwitchId is specified when you call this operation,VSwitchId must belong to the current VPC.
  • If VSwitchId is specified when you call this operation but PrivateIpAddress is not specified, the system automatically allocates a private IP address to the ECS instance.
  • The current VSwitch and the new VSwitch (VSwitchId) must belong to a zone in the same region.
  • The current VSwitch and the new VSwitch (VSwitchId) must belong to the same VPC.
  • If both VSwitchId and PrivateIpAddress are specified, the private IP address must belong to the CIDR block of the specified VSwitch. PrivateIpAddress depends on VSwitchId, so you cannot specify only PrivateIpAddress.

Debugging

You can use API Explorer to perform debugging. API Explorer allows you to perform various operations to simplify API usage. For example, you can retrieve APIs, call APIs, and dynamically generate SDK example code.

Request parameters

Name Type Required Example Description
InstanceId String Yes i-bp1iudwa5b1tqaxxxxxx

The ID of the instance.

VSwitchId String Yes vswitchid

The ID of the new VSwitch. The current switch and the new switch (VSwitchId) must belong to a zone in the same region.

Action String No ModifyInstanceVpcAttribute

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

PrivateIpAddress String No 172.17. XX.XXX

The new private IP address of the instance.PrivateIpAddress depends on VSwitchId, so you cannot specify only PrivateIpAddress.

Response parameters

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

The request ID.

Examples

Sample requests

https://ecs.aliyuncs.com/?Action=ModifyInstanceVpcAttribute
&InstanceId=i-bp1iudwa5b1tqaxxxxxx
&VSwitchId=[vswitchid] 
&<Common request parameters>

Successful response examples

XML format

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

JSON format

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

Error codes

HTTP status code Error code Error message Description
400 InvalidPrivateIpAddress.Malformed Specified private IP address is malformed. The error message returned when the specified private IP address is invalid.
400 IncorrectVSwitchStatus The current status of virtual switch does not support this operation. The error message returned when the specified VSwitch is in the pending state and cannot be deleted.
404 InvalidVSwitchId.NotFound Specified virtual switch does not exist. The error message returned when the specified VSwitch does not exist.
400 IncorrectInstanceStatus The current status of instance does not support this operation. The error message returned when the operation is not supported while the instance is in the current state.
400 OperationDenied Specified operation is denied as your instance is not in VPC. The error message returned when the specified operation is denied because the instance is not in the VPC.
400 InvalidPrivateIpAddress.Mismatch Specified private IP address is not in the CIDR block of virtual switch. The error message returned when the specified private IP address is not in the CIDR block of the specified VSwitch.
404 NoSuchResource The specified resource is not found. The error message returned when the specified resource does not exist.

View error codes