Register data sources across Alibaba Cloud accounts
To register a database instance that belongs to another Alibaba Cloud account (primary account) in Agent Data Gateway, you must first complete RAM authorization in the resource owner's account, and then turn on cross-account access and enter the role ARN in the gateway. This topic describes how to configure cross-account data source registration. The configuration method is consistent with DMS.
Prerequisites
This topic involves two Alibaba Cloud accounts (primary accounts):
Account A (gateway user): has activated Agent Data Gateway and registers the data source in the gateway. For more information about how to activate the gateway, see Manage data sources.
Account B (resource owner): the account to which the database instance to be registered belongs. This account completes the RAM authorization configuration.
Usage notes
Only Alibaba Cloud instances can be registered across accounts.
Cloud-hosted instances, such as ApsaraDB RDS for MySQL instances, cannot be registered over the Internet. You can register them by synchronizing DMS instances. For more information, see Synchronize DMS instances.
The resource owner (Account B) must have logged on to DMS.
Step 1: Create a RAM role and configure a trust policy
Perform the following operations in Account B (the resource owner).
Log on to the RAM console as a RAM user that has the
AliyunRAMFullAccesspermission.In the left-side navigation pane, choose Identities > Roles.
Click Create Role and configure a trust policy.
Parameter
Description
Principal Type
Select Alibaba Cloud Account.
Principal Name
Select Other Account and enter the UID of Account A.
In the upper-right corner, click Switch to Policy Editor and use either of the following methods to configure the trust policy:
Method 1: Visual editor: On the Visual Editor tab, set Principal to Cloud Service and click Edit in the Cloud Service section. In the Add Principal dialog box, set Cloud Account to Other Account and enter the UID of Account A. Set Cloud Service to Data Management / DMSEnterprise and click OK.
Method 2: Script editor: On the JSON Editor tab, enter the following trust policy. Replace
<UID of Account A>with the actual UID of Account A, and then click OK.{ "Version": "1", "Statement": [ { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { "Service": [ "<UID of Account A>@dms.aliyuncs.com" ] } } ] }
In the Create Role dialog box, enter a role name, such as
dms-cross-account-role, and click OK.
Step 2: Create a cross-account permission policy
In the left-side navigation pane, choose Permissions > Policies.
Click Create Policy.
Click the JSON Editor tab, select the permission policy for the data source type that you want to register, and copy its content to the editor.
NoteFor RDS, PolarDB for MySQL, PolarDB for PostgreSQL, and PolarDB for PostgreSQL (Compatible with Oracle), you do not need to create a permission policy or attach it to the role (skip Step 2 and Step 3). You can directly obtain the role ARN.
Click OK, enter a policy name, such as
DmsCrossAccountPolicy, and then click OK.
Step 3: Attach the policy to the RAM role and obtain the ARN
In the left-side navigation pane, choose Identities > Roles.
In the Actions column of the role created in Step 1, click Attach Policy.
In the Grant Permission panel, search for and select the custom policy created in Step 2 in the Policy section, and then click OK.
Click the name of the target role. In the Basic Information section of the role details page, copy the role ARN for use in Step 4.
Step 4: Register the data source in Agent Data Gateway
Perform the following operations in Account A (the gateway user).
Log on to the AI-Native Database Service console.
In the upper-left corner, click the
icon, and then click Agent Data Gateway to go to the Agent Data Gateway console.In the left-side navigation pane of the console, click Data Sources.
Click Add Data Source.
Turn on the Cross-account access switch and enter the ARN of the role created in Account B.
Select the Database Type and Instance Source of the data source that you want to register. Set Entry Method to Connection String and enter the endpoint and port number of the target instance.
Enter the Database Account and Database Password.
Click Test Connection. After the connection is verified, click Submit.
Verify the registration result
On the Connection Management page, confirm that the status of the target data source is normal. This indicates that the cross-account registration is successful. You can then grant agents access to the data source. For more information, see Manage data sources.
FAQ
Issue | Possible cause and solution |
The connection test fails with a message indicating that the role cannot be assumed | The service principal or the UID of Account A in the trust policy is incorrect. Check the trust policy in Step 1 and make sure that the service principal and UID are correct. |
The connection test fails with a message indicating insufficient permissions | The permission policy is not attached to the role, or the policy does not cover the target instance type. Make sure that the policy in Step 2 covers the database type and that the policy is attached to the role in Step 3. |
The ARN is reported as invalid | The ARN is incomplete or the role does not belong to Account B. Copy the complete ARN again from the Basic Information section of the role in Account B. |
The connection times out or instance information cannot be retrieved | Make sure that Account B has logged on to DMS and that the region of the instance is the same as the region selected during registration. For cloud-hosted instances, register them by synchronizing DMS instances instead. |