All Products
Search
Document Center

ApsaraDB for MongoDB:Connect an ECS instance to an ApsaraDB for MongoDB instance within a different Alibaba Cloud account over the internal network

Last Updated:Mar 28, 2026

If your Elastic Compute Service (ECS) instance and ApsaraDB for MongoDB instance belong to different Alibaba Cloud accounts, use one of the following methods to connect them over the internal network without routing traffic through the public internet.

Choose a method

MethodHow it worksWhen to use
Method 1: Migrate MongoDB via DTSUses Data Transmission Service (DTS) to move the MongoDB database to the ECS accountYou can accept a data migration window and want long-term account consolidation
Method 2: Migrate ECS via custom imageShares the ECS instance as a custom image and recreates it in the MongoDB accountBoth instances are in the same region
Method 3: Connect VPCs via CENUses Cloud Enterprise Network (CEN) to connect virtual private clouds (VPCs) across accounts without migrating any instanceBoth instances use VPC networking and VPC CIDR blocks do not conflict

Method 1: Migrate the ApsaraDB for MongoDB instance to the Alibaba Cloud account to which the ECS instance belongs

This method uses the DTS data migration feature to move the ApsaraDB for MongoDB database to the ECS account, placing both instances in the same account.

Steps

  1. Create an ApsaraDB for MongoDB instance in the Alibaba Cloud account that owns the ECS instance. The new instance must be in the same region, zone, and VPC as the ECS instance. For details, see Create an instance.

    Select the same VPC as the ECS instance when creating the ApsaraDB for MongoDB instance. Skip this step if such an instance already exists.
  2. Migrate the ApsaraDB for MongoDB database to the ECS account using DTS. For details, see Migrate data between ApsaraDB for MongoDB instances of different Alibaba Cloud accounts. For an overview of DTS, see What is DTS?

  3. Add the ECS instance's IP address to all IP address whitelists of the ApsaraDB for MongoDB instance. For details, see Modify an IP address whitelist of an ApsaraDB for MongoDB instance.

    To find the IP address of your ECS instance, see View instance information.

Method 2: Migrate the ECS instance to the Alibaba Cloud account to which the ApsaraDB for MongoDB instance belongs

This method recreates the ECS instance in the MongoDB account by sharing it as a custom image, so both instances end up in the same account.

Prerequisites

The ECS instance (Alibaba Cloud account A) and the ApsaraDB for MongoDB instance (Alibaba Cloud account B) must be in the same region.

If they are in different regions, copy the custom image to the target region before sharing it, or share the image first and then copy it cross-region. For details, see Copy a custom image.

Steps

  1. Create a custom image from the ECS instance. For details, see Create a custom image from an instance.

  2. Share the custom image to Alibaba Cloud account B (the account that owns the ApsaraDB for MongoDB instance). For details, see Share a custom image.

  3. In Alibaba Cloud account B, create an ECS instance from the shared custom image. For details, see Create an ECS instance from a custom image.

    Select the same VPC as the ApsaraDB for MongoDB instance when creating the ECS instance.
  4. Add the new ECS instance's IP address to all IP address whitelists of the ApsaraDB for MongoDB instance. For details, see Modify an IP address whitelist of an ApsaraDB for MongoDB instance.

    To find the IP address of your ECS instance, see View instance information.

Method 3: Establish a connection between the ECS instance and the ApsaraDB for MongoDB instance by using CEN

This method uses CEN to connect the VPCs of both accounts over the internal network, without migrating any instance. For an overview of CEN, see What is CEN?

Prerequisites

Before you begin, confirm that the CIDR blocks of the involved VPCs or vSwitches do not conflict with each other.

Steps

  1. Switch the ApsaraDB for MongoDB instance's network type to VPC. For details, see Switch the network type of an ApsaraDB for MongoDB instance from classic network to VPC. Skip this step if the instance is already on VPC.

  2. Switch the ECS instance's network type to VPC. For details, see Migrate ECS instances from a classic network to a VPC. Skip this step if the instance is already on VPC.

  3. Connect the two VPCs using CEN. Choose the guide that matches your deployment:

  4. Add the ECS instance's IP address to all IP address whitelists of the ApsaraDB for MongoDB instance. For details, see Modify an IP address whitelist of an ApsaraDB for MongoDB instance.

    To find the IP address of your ECS instance, see View instance information.