All Products
Search
Document Center

Elastic Compute Service:change the VPC of an ECS instance

Last Updated:Feb 27, 2024

If the virtual private cloud (VPC) that you selected when you created an Elastic Compute Service (ECS) instance does not meet your business requirements or if you want to re-plan the network of an ECS instance, you can change the VPC of the instance. This topic describes how to change the VPC of an ECS instance.

Prerequisites

  • The ECS instance whose VPC you want to change is in the Stopped state. For information about how to stop an ECS instance, see Stop an instance.

    Note

    If the ECS instance has not been restarted after it is created, you must restart it before you stop it.

  • The ECS instance is not added as a backend server to the server group of a Server Load Balancer (SLB) instance. For information about how to remove an ECS instance as a backend server from the server group of an SLB instance, see Add an ECS instance to the default server group.

  • All secondary elastic network interfaces (ENIs) are unbound from the ECS instance. The secondary private IP addresses that are assigned to the ENIs are unassigned. For more information, see Unbind an ENI and Unassign secondary private IP addresses.

  • The ECS instance is not connected by using its private IP address. If the ECS instance is connected by using its private IP address, a private link is generated for the instance and the VPC of the instance cannot be changed. Release the private link before you change the VPC of the instance.

  • VPCs, vSwitches, and security groups are created and available.

Scenarios

  • You want to re-plan the VPCs of your ECS instances because the original VPCs are unable to keep up with the increasing needs of your business.

  • In the early business stage, only one VPC was planned. Different projects and usage environments shared the VPC, which resulted in risks stemming from data operations. You want to use different VPCs for different projects and environments.

  • Your ECS instances are deployed in the default VPCs of different accounts. ECS instances that reside in different VPCs cannot connect to each other across Alibaba Cloud accounts due to IP address conflicts. To ensure that the ECS instances within different Alibaba Cloud accounts can connect to each other, you must change the VPCs of the instances and resolve the IP address conflicts.

Limits

  • The ECS instance cannot be used in other cloud services. For example, the instance cannot be in the process of migration or having its VPC changed, or the databases deployed on the instance cannot be managed by Data Transmission Service (DTS).

  • After the VPC is changed, the new vSwitch of the ECS instance must reside within the same zone as the original vSwitch.

  • When you change the VPC of an ECS instance, you must select one to five security groups of the same type (basic or advanced) for the instance.

  • ECS instances of specific instance families do not support changing to VPCs that have advanced features enabled. For information about ECS instance families that do not support advanced VPC features, see Instance families that do not support advanced VPC features.

  • You can change the VPCs of up to 20 ECS instances at a time.

  • After you change the VPC of an ECS instance, the instance can no longer communicate with other ECS instances in the original VPC. You can use Express Connect for the instance to communicate with other ECS instances in the original VPC. For information about Express Connect, see What is Express Connect?

  • The cut-through mode or the multi-EIP-to-ENI mode cannot be enabled for the ECS instance.

  • The ECS instance cannot be associated with a high-availability virtual IP address (HAVIP).

  • The vSwitch of the ECS instance cannot be associated with a custom route table.

  • Global Accelerator (GA) cannot be activated for the ECS instance.

  • The ECS instance cannot have secondary ENIs.

  • The ECS instance cannot be assigned an IPv6 address.

  • The primary ENI of the ECS instance cannot be associated with multiple IP addresses.

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 the region and resource group to which the resource belongs. 地域

  4. Change the VPCs of one or more ECS instances at a time.

    • Change the VPC of a single ECS instance

      Find the ECS instance whose VPC you want to change. In the Actions column, choose icon1 > Network and Security Group > Change VPC.

    • Change the VPCs of multiple ECS instances at a time

      Select the ECS instances whose VPCs you want to change and choose More > Network and Security Group > Change VPC in the lower part of the page.

  5. In the Change VPC dialog box, follow the instructions to change the VPCs of the instances.

    1. In the Make Preparations step, check the network information and precautions and click Next.

    2. In the Select VPC step, select a new VPC, a new vSwitch, and new security groups from the Destination VPC, Destination VSwitch, and Destination Security Group drop-down lists and click Next.

    3. (Optional) In the Configure Primary Private IP Address step, specify a new primary private IP address for each ECS instance.

      • The primary private IP addresses must be within the CIDR block of the destination vSwitch.

      • If you do not manually specify the primary private IP address for an ECS instance, the system assigns a primary private IP address.

    4. Click OK.

Results

  • After the VPC of an ECS instance is changed, click the ID of the instance and check the new VPC and vSwitch in the Network Information section on the Instance Details tab.

  • If you configured event notifications for VPC changes of ECS instances in EventBridge or CloudMonitor, you receive a vSwitch change event notification.