This topic describes how to migrate a VPC-type ECS instance from one virtual private cloud (VPC) to another VPC. If you select an inappropriate VPC when you create an ECS instance or if you want to re-plan the network, you can use this feature to change the VPC of the instance.

Prerequisites

  • The instance is in the Stopped state. For more information, see Stop an instance.
  • The ECS instance is not added as a backend server to a Server Load Balancer (SLB) instance. For information about how to remove a backend server of an SLB instance, see Remove a backend server.
  • All the secondary elastic network interfaces (ENIs) that are attached to the ECS instance are detached, and all secondary private IP addresses are revoked from the primary and secondary ENIs that are attached to the ECS instance. For more information about how to detach secondary ENIs and revoke secondary private IP addresses, see Detach an ENI from an instance and Revoke secondary private IP addresses.
  • The destination VPC, VSwitch, and security groups are created and available for use.

Scenarios

  • You want to replan the VPC of your ECS instance because the original VPC is unable to keep up with the growing needs of your business.
  • In the early business stage, only one VPC was planned. Different projects and usage environments share this VPC, which leads to risks in data operations. Now you want to separate this VPC based on projects and usage environments.
  • Your ECS instances are deployed in the default VPCs in different accounts. As a result, connectivity between instances across Alibaba Cloud accounts cannot be implemented due to IP address conflicts. In this case, you must change the VPCs of the ECS instances and resolve the address conflict before you interconnect the instances across Alibaba Cloud accounts.

Limits

  • The instance for which you want to change the VPC cannot be in the Locked, To Be Released, Expired, To Be Recycled, Expired and Being Recycled, or Overdue and Being Recycled state. The instance cannot be in the process of migration or VPC change.
  • After the VPC is changed, the new VSwitch of the instance must be in the same zone as the original VSwitch.
  • You can select up to five security groups in each destination VPC for an instance. However, the destination security groups must be of the same type, basic security group or advanced security group.
  • If advanced VPC features are enabled for the destination VPC, you cannot migrate instances of certain instance families to the destination VPC. For information about unsupported ECS instance families, see Instance families that do not support advanced VPC features.
  • You can change the same VPC of up to 20 ECS instances at a time.
  • After you change the VPC of an ECS instance, the ECS instance cannot communicate with other ECS instances in the original VPC.

Procedure

  1. Log on to the ECS console.
  2. In the left-side navigation pane, choose Instances & Images > Instances.
  3. In the top navigation bar, select a region.
  4. Change the VPC of one or more ECS instances at a time.
    • Change the VPC of a single ECS instance

      Find the target ECS instance. Then, click More in the Actions column and choose Network and Security Group > ecs.vm.action.change_vpc.

    • Change the same VPC of multiple ECS instances at a time

      Select multiple target ECS instances, click More in the lower part, and choose Network and Security Groups > ecs.vm.action.change_vpc.

  5. In the Change VPC wizard, follow the instructions to change the VPC of the ECS instances.
    Change the VPC
    1. In the Prepare step, view the pre-change network information and precautions and click Next.
    2. In the Select VPC step, configure the Destination VPC, Destination VSwitch, and Destination Security Group parameters, and then click Next.
    3. Optional: In the Configure Primary Private IP Address step, set the primary private IP address for each of the selected ECS instances after their VPC is changed.
      • The primary private IP address must be within the CIDR block of the destination VSwitch.
      • If you do not manually set the primary private IP address, it is automatically assigned by the system.
    4. Click OK.

After the VPC is changed, you can click the instance IDs, view the new VPC and VSwitch in the Configuration Information section of the Instance Details page.