This guide explains how to connect a data source hosted on an Alibaba Cloud Elastic Compute Service (ECS) instance to DataWorks. It uses a MySQL database as the example, but the same approach applies to any DataWorks-supported data source running on ECS.
Choose a connectivity approach
Your configuration path depends on how your ECS instance and DataWorks workspace relate to each other. Use the following table to identify your scenario and jump to the relevant steps.
| Scenario | Account relationship | Region relationship | Recommended approach |
|---|---|---|---|
| Same account and region | Same | Same | Deploy the DataWorks resource group and ECS instance in the same Virtual Private Cloud (VPC), or associate the ECS VPC with the resource group |
| Same account, different regions | Same | Different | Connect the two VPCs using Cloud Enterprise Network (CEN) or a VPC Peering Connection |
| Different accounts | Different | Same or different | Connect the two VPCs using CEN or a VPC Peering Connection |
When to use CEN vs. VPC Peering Connection:
Cloud Enterprise Network (CEN): Use for complex enterprise networks that require connectivity across multiple VPCs.
VPC Peering Connection: Use for a direct, point-to-point connection between exactly two VPCs.
How it works
Same account and region
Deploy the DataWorks resource group and ECS instance in the same VPC to establish network communication over a private connection.
Same account, different regions
Use CEN or a VPC Peering Connection to link the VPC of the DataWorks resource group with the VPC of the ECS instance across regions.
Different accounts
Use CEN or a VPC Peering Connection to link the VPC of the DataWorks resource group with the VPC of the ECS instance across accounts.
Prerequisites
Before you begin, make sure you have:
A DataWorks-supported data source deployed on an ECS instance
Billing
Charges vary depending on the networking product you choose. For details, see the billing documentation for Cloud Enterprise Network (CEN) or VPC Peering Connection.
No fees are charged when you use a VPC Peering Connection to connect ECS instances and DataWorks resource groups that are in different accounts but the same region.
Configure network connectivity
The following steps outline the general procedure. For a detailed walkthrough of a cross-account, cross-region scenario, see the Configuration example in this topic.
Step 1: Get the required information
Collect the VPC and vSwitch details for both the ECS instance and the DataWorks resource group. The information you need depends on your scenario.
Same account and region
Data source (ECS instance)
Go to the Elastic Compute Service console. In the top navigation bar, select the region where your ECS instance is located.
In the left-side navigation pane, choose Instances. Find the ECS instance that hosts your database and click the instance name to open the Instance Details page.
In the Configuration Information section, note the VPC (referred to as
VPC 1in this guide) and vSwitch values.
DataWorks resource group
Go to the DataWorks resource group list. Find the target resource group and click Network Settings in the Actions column.
Under the relevant feature module, note the VPC (referred to as
VPC 2in this guide) and vSwitch values. For example, for data synchronization, check the VPC and vSwitch under Data Scheduling & Data Integration.
Same account, different regions
Data source (ECS instance)
Region: Note the region where the ECS instance is located. This example uses China (Hangzhou).
VPC and vSwitch:
Go to the Elastic Compute Service console. In the top navigation bar, select the region where your ECS instance is located.
In the left-side navigation pane, choose Instances. Find the ECS instance that hosts your database and click the instance name to open the Instance Details page.
In the Configuration Information section, note the VPC and vSwitch values.

DataWorks resource group
Region: Note the region where the DataWorks workspace and resource group are located. This example uses China (Shanghai).
VPC and vSwitch:
Go to the DataWorks resource group list. Find the target resource group and click Network Settings in the Actions column.
Under the relevant feature module, note the VPC and vSwitch values. For example, for data synchronization, check the VPC and vSwitch under Data Scheduling & Data Integration.

Different accounts
Data source (ECS instance)
Account: This example uses Account A.
Region: This example uses the China (Hangzhou) region.
VPC and vSwitch:
Go to the Elastic Compute Service console. In the top navigation bar, select the region where your ECS instance is located.
In the left-side navigation pane, choose Instances. Find the ECS instance that hosts your database and click the instance name to open the Instance Details page.
In the Configuration Information section, note the VPC and vSwitch values.

DataWorks resource group
Account: This example uses Account B.
Region: This example uses the China (Shanghai) region.
VPC and vSwitch:
Go to the DataWorks resource group list. Find the target resource group and click Network Settings in the Actions column.
Under the relevant feature module, note the VPC and vSwitch values. For example, for data synchronization, check the VPC and vSwitch under Data Scheduling & Data Integration.

Step 2: Establish a network connection
Same account and region
If
VPC 1andVPC 2are the same, the ECS instance and the DataWorks resource group are already in the same VPC. Network connectivity is established by default — skip to Step 5: Configure the security group.If
VPC 1andVPC 2are different, go to the network settings page of the DataWorks resource group and click Add VPC Association to associateVPC 1with the resource group. This places both the resource group and the ECS instance in the same VPC. After the association is saved, the network settings page showsVPC 1listed under the resource group's associated VPCs.
Same account, different regions
Connect the two VPCs using one of the following options:
Cloud Enterprise Network (CEN): For configuration details, see Connect VPCs across regions.
VPC Peering Connection: For configuration details, see Use a VPC Peering Connection to connect VPCs.
If you encounter issues while establishing the connection, submit a ticket to contact technical support for the relevant cloud product.
Different accounts
Connect the two VPCs using one of the following options:
Cloud Enterprise Network (CEN): For configuration details, see Connect VPCs across accounts.
VPC Peering Connection: For configuration details, see Use a VPC Peering Connection to connect VPCs.
If you encounter issues while establishing the connection, submit a ticket to contact technical support for the relevant cloud product.
Step 3: Add a route to the resource group
This step is required only for cross-region or cross-account scenarios. Skip this step if the ECS instance and the DataWorks workspace are in the same account and region.
Add a route in the DataWorks resource group that points to the CIDR block of the ECS instance's vSwitch.
Go to the DataWorks resource group list. Find the target resource group and click Network Settings in the Actions column.
Under the relevant feature module, find the associated VPC and click Custom Route in the Actions column.
Click Add Route. Set the connection method to CIDR Block and set Destination CIDR Block to the CIDR block of the ECS instance's vSwitch.
After saving, the route entry appears in the custom route list for the associated VPC.
Step 4: (Optional) Enable remote database access
Some databases require you to configure the database to accept connections from external IP addresses. The exact steps vary by database — refer to your database's official documentation.
For MySQL-specific instructions, see step 4 in the configuration example.
Step 5: Configure the security group
ECS security groups act as firewalls. Add an inbound rule to the security group of the ECS instance to open the database port to the CIDR block of the DataWorks resource group's vSwitch.
Go to the Elastic Compute Service console. In the top navigation bar, select the region where your ECS instance is located.
In the left-side navigation pane, choose Instances. Find the ECS instance that hosts your database and click the instance name to open the Instance Details page.
Click the Security Groups tab, then click the name of the security group to open the Security Group Details page.
In the Rules section, click Add Rule and configure the following parameters. Keep the default values for all other parameters.
Parameter Value Source The CIDR block of the DataWorks resource group's vSwitch Port Range The port used by your database (see the table below)
Common database ports:
| Database | Default port |
|---|---|
| MySQL | 3306 |
| PostgreSQL | 5432 |
| SQL Server | 1433 |
| Oracle | 1521 |
| MongoDB | 27017 |
| Redis | 6379 |
Verify network connectivity
After completing the configuration steps, test the connection from DataWorks.
Log on to the DataWorks console. In the top navigation bar, select the target region. In the left-side navigation pane, choose Data Integration > Data Integration. Select the target workspace from the drop-down list and click Go to Data Integration.
In the left-side navigation pane, click Data source. On the Data Sources page, click Add Data Source. Select the appropriate data source type and configure the connection parameters.
In the resource group list at the bottom of the page, select the resource group connected to the data source and click Test Network Connectivitysubmit a ticket.

If the test returns Connection failed, use the Network Connectivity Diagnosis Tool to identify the issue. If the problem persists, submit a ticket.
Configuration example
This example walks through a cross-account, cross-region scenario: a MySQL database runs on an ECS instance in the China (Hangzhou) region under Account A, and the DataWorks workspace is in the China (Shanghai) region under Account B.
1. Basic information
|
Parameter |
Data source |
DataWorks resource group |
|
Account |
Account A |
Account B |
|
Region |
China (Hangzhou) |
China (Shanghai) |
|
VPC |
ECS basic information page:
|
Resource group network settings page:
|
2. Establish network connection
This example uses a VPC Peering Connection to connect the ECS instance to DataWorks.
If you encounter issues while establishing the connection, submit a ticket to contact technical support for the relevant cloud product.
Log on to Account A. Go to the VPC Peering Connection console. In the top navigation bar, select the China (Hangzhou) region, then click Create Peering Connection. Configure the following key parameters. Keep the default values for all other parameters.
Parameter Configuration Peering connection name Enter a custom name. This example uses Account_A to Account_B.Requester VPC instance The VPC in Account A that contains the ECS instance. This example uses Account_A_hangzhou_VPC.Accepter account type Select Cross-account.Accepter Alibaba Cloud account UID Enter the UID of the Alibaba Cloud account for Account B. Accepter region type Select Cross-region.Accepter region The region of the DataWorks workspace and resource group in Account B. Select China (Shanghai).Accepter VPC instance Manually enter the ID of the VPC associated with the DataWorks resource group in Account B ( Account_B_shanghai_VPC).Click OK. The peering connection is created with a Status of Pending Acceptance.
Log on to Account B. Go to the VPC Peering Connection console. In the top navigation bar, select the China (Shanghai) region. Find the incoming peering connection request and click Accept in the Actions column. After acceptance, the Status changes to Activated.
Click Configure Route under the Accepter VPC Instance. In the dialog box, enter a custom name for the route entry. Set Destination CIDR Block to the VPC CIDR block of the requester (the ECS instance):
192.168.0.0/16.
Log on to Account A. Go to the VPC Peering Connection console. In the top navigation bar, select the China (Hangzhou) region and find the peering connection you created.
Click Configure Route under the Requester VPC Instance. In the dialog box, enter a custom name for the route entry. Set Destination CIDR Block to the VPC CIDR block of the accepter (the DataWorks resource group):
172.16.0.0/12.
3. Add a route to the resource group
Log on to Account B. Go to the DataWorks resource group list. Find the target resource group and click Network Settings in the Actions column.
Under the relevant feature module, find the associated VPC and click Custom Route in the Actions column.
Click Add Route. For Connection Method, select CIDR Block. For Destination CIDR Block, enter the CIDR block of the vSwitch where the ECS instance is located:
192.168.6.0/24.
4. Enable remote database access
Connect to the ECS instance that hosts the MySQL database and enable remote access.
The following commands apply to MySQL 8.0 on Linux. Adapt the steps for other operating systems or MySQL versions.
Find the
my.cnfconfiguration file. With a default installation, it is typically at/etc/my.cnf.find / -name my.cnfOpen the file for editing. Replace the path if your
my.cnfis in a different location.vim /etc/my.cnfAt the end of the file, press
ito enter insert mode and add the following line under[mysqld]:bind-address=0.0.0.0Press
Esc, then enter:wq!to save and exit.Restart the MySQL service.
systemctl restart mysqldCreate a database user for DataWorks to use when connecting remotely.
Log on to the database as the administrator.
mysql -u root -pCreate a user and set a password.
-- "dataworks_user" is the username. Customize as needed. -- "%" allows connections from any IP address. Replace with a specific IP for finer-grained control. -- "StrongPassword123!" is the password. Customize as needed. CREATE USER 'dataworks_user'@'%' IDENTIFIED BY 'StrongPassword123!';Grant the user access to the database.
-- Run one of the following commands. -- Grants all privileges on all databases. Use with caution. GRANT ALL PRIVILEGES ON *.* TO 'dataworks_user'@'%' WITH GRANT OPTION; -- Grants privileges on a specific database (for example, mydatabase). GRANT ALL PRIVILEGES ON mydatabase.* TO 'dataworks_user'@'%' WITH GRANT OPTION;Flush the privileges, then exit.
FLUSH PRIVILEGES;exitVerify the remote connection.
mysql -u dataworks_user -h <Private_IP_address_of_the_ECS_instance> -p
5. Configure the security group
Log on to Account A. Go to the Elastic Compute Service console. In the top navigation bar, select the China (Hangzhou) region.
In the left-side navigation pane, choose Instances. Find the ECS instance that hosts the MySQL database and click the instance name to open the Instance Details page.
Click the Security Groups tab, then click the name of the security group to open the Security Group Details page.
In the Rules section, click Add Rule and configure the following parameters. Keep the default values for all other parameters.
Parameter Value Source The CIDR block of the DataWorks resource group's vSwitch: 172.16.66.0/24Port Range 3306
6. Test the connection
Log on to Account B.
Log on to the DataWorks console. In the top navigation bar, select the target region. In the left-side navigation pane, choose Data Integration > Data Integration. Select the target workspace from the drop-down list and click Go to Data Integration.
In the left-side navigation pane, click Data source to open the Data Sources page, then click Add Data Source.
Select the MySQL data source type and configure the following parameters.
Parameter Value Configuration Mode Connection String Mode Host IP Address The private IP address of the ECS instance: 192.168.6.172Port Number 3306Database Name The name of an existing database Username dataworks_user(created in step 4)Password The password set in step 4 In the Connection Configuration section, click Test Network Connectivity for the associated resource group. Verify that the result is passed.
If the connectivity test fails, use the Network Connectivity Diagnosis Tool to troubleshoot. If the problem persists, submit a ticket for assistance.

What's next
For frequently asked questions about network connectivity, see Resource group operations and network connectivity.




