You can call the SwitchDBInstanceVpc operation to change the virtual private cloud (VPC) or vSwitch of an instance.

The instance must run one of the following database engines:

  • MySQL with local SSDs, standard SSDs, or enhanced SSDs (ESSDs)
  • SQL Server with standard SSDs or ESSDs
  • MariaDB with standard SSDs or ESSDs
  • PostgreSQL with standard SSDs or ESSDs

For more information about the impact of VPC and vSwitch changes, see Switch an ApsaraDB RDS for MySQL instance to a new VPC and a new vSwitch.

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

ParameterTypeRequiredExampleDescription
ActionStringYesSwitchDBInstanceVpc

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

DBInstanceIdStringYesrm-uf6wjk5*******

The ID of the instance.

Note
  • The instance must run one of the following database engines:
    • MySQL with local SSDs, standard SSDs, or ESSDs
    • SQL Server with standard SSDs or ESSDs
    • MariaDB with standard SSDs or ESSDs
    • PostgreSQL with standard SSDs or ESSDs
  • The instance must be in the Running state.
  • The instance must reside in a VPC.
  • The instance cannot be a temporary instance or use an instance type that belongs to the shared instance family.
VPCIdStringYesvpc-uf6f7l4fg90**********

The ID of the VPC.

Note The VPC must belong to the same region as the instance.
VSwitchIdStringYesvsw-uf6adz52c2p**********

The ID of the vSwitch.

Note The vSwitch must belong to the same zone as the instance.
PrivateIpAddressStringNo10.23.**.**

The private IP address of the instance. The private IP address must be within the CIDR block of the vSwitch that is specified by the VSwitchId parameter.

Note You can call the DescribeVSwitches operation to query the CIDR block of the vSwitch.

Response parameters

ParameterTypeExampleDescription
RequestIdString777C4593-8053-427B-99E2-10xxxxxxxxxx

The ID of the request.

Examples

Sample requests

http(s)://rds.aliyuncs.com/?Action=SwitchDBInstanceVpc
&DBInstanceId=rm-uf6wjk5xxxxxxx     
&VPCId=vpc-uf6f7l4fg90xxxxxxxxxx
&VSwitchId=vsw-uf6adz52c2pxxxxxxxxxx
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<RequestId>777C4593-8053-427B-99E2-10xxxxxxxxxx     </RequestId>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "777C4593-8053-427B-99E2-10xxxxxxxxxx"
}

Error codes

HTTP status codeError codeError messageDescription
400MigrateAlreadyExistsFaultDuplicate migration is forbidden.The error message returned because a duplicate migration task is found.
400InvalidConnVPCIdSpecified conn vpc id is not valid.The error message returned because the specified VPC ID is invalid.
400InvalidInstanceKind.NotSupportThe instance kind does not support this operation.The error message returned because the operation is not supported by the configuration of the instance.
400InvalidPrivateIpAddress.MismatchSpecified private IP address is not in the CIDR block of virtual switch.The error message returned because the specified PrivateIpAddress parameter is invalid.
400MigrateAlreadyReadWriteSplitExistsFaultThe rds instance already has a given vpc migrate task.The error message returned because a VPC migration task is created for the instance.

For a list of error codes, visit the API Error Center.