You can use a Resource Access Management (RAM) role to grant permissions across Alibaba Cloud accounts. This way, an enterprise can access Message Queue for RabbitMQ of another enterprise.

Background information

Enterprise A has activated Message Queue for RabbitMQ. Enterprise A requires Enterprise B to manage Message Queue for RabbitMQ resources, such as instances, queues, vhosts, and exchanges. Enterprise A has the following requirements:
  • Enterprise A wants to focus on its business systems and act only as the owner of Message Queue for RabbitMQ. Enterprise A can authorize Enterprise B to maintain, monitor, and manage Message Queue for RabbitMQ.
  • When an employee joins or leaves Enterprise B, no permission change is required. Enterprise B can grant fine-grained permissions on cloud resources of Enterprise A to its RAM users (employees or applications).
  • If the agreement between Enterprise A and Enterprise B ends, Enterprise A can revoke the permissions from Enterprise B.

Step 1: Enterprise A creates a RAM role

Use the Alibaba Cloud account of Enterprise A to log on to the RAM console, and create a RAM role for the Alibaba Cloud account of Enterprise B.

  1. Log on to the RAM console.
  2. In the left-side navigation pane, click RAM Roles.
  3. On the RAM Roles page, click Create RAM Role.
  4. In the Create RAM Role panel, select Alibaba Cloud Account and click Next.
  5. In the RAM Role Name field, enter a RAM role name. In the Select Trusted Alibaba Cloud Account section, select Other Alibaba Cloud Account, and enter the ID of the Alibaba Cloud account of Enterprise B. Then, click OK.
    Note
    • A RAM role name cannot exceed 64 characters in length and can contain only letters, digits, and hyphens (-).
    • You can view the account ID on the Security Settings page.

Step 2: Enterprise A grants permissions to the RAM role

Grant the RAM role the permissions to access Message Queue for RabbitMQ of Enterprise A.

  1. In the left-side navigation pane of the RAM console, click RAM Roles.
  2. On the RAM Roles page, find the created RAM role, and click Add Permissions in the Actions column.
  3. In the Select Policy section of the Add Permissions panel, click System Policy or Custom Policy. Enter the keyword of the policy that you want to add in the search box, click the displayed policy to add it to the Selected list, and then click OK.
    Note For more information about the policies that can be assigned to access Message Queue for RabbitMQ, see RAM policies.
  4. In the Add Permissions panel, view the authorization information and click Complete.

Step 3: Enterprise B creates a RAM user

Use the Alibaba Cloud account of Enterprise B to log on to the RAM console and create a RAM user.

  1. Log on to the RAM console.
  2. In the left-side navigation pane, choose Identities > Users.
  3. On the Users page, click Create User.
  4. In the User Account Information section of the Create User page, specify Logon Name and Display Name.
    Note
    • A logon name cannot exceed 128 characters in length and can contain only letters, digits, periods (.), underscores (_), and hyphens (-).
    • A display name cannot exceed 24 characters in length.
  5. Optional:To create multiple RAM users, click Add User and repeat the previous step.
  6. In the Access Mode section, select an access mode and click OK.
    Note For security purposes, we recommend that you select only one access mode.
    • If you select Console Access, you must configure Console Password, Password Reset, and Multi-factor Authentication.
    • If you select Programmatic Access, an AccessKey pair is automatically created for the RAM user.
      Notice For security purposes, the RAM console allows you to view or download the AccessKey secret only once. Therefore, when you create an AccessKey pair, you must record the AccessKey secret and keep it strictly confidential.

Step 4: Enterprise B grants permissions to the RAM user

Attach the AliyunSTSAssumeRoleAccess policy to the RAM user.

  1. In the left-side navigation pane of the RAM console, choose Identities > Users.
  2. On the Users page, find the created RAM user and click Add Permissions in the Actions column.
  3. In the Select Policy section of the Add Permissions panel, click System Policy, enter AliyunSTSAssumeRoleAccess in the search box, click the policy to add it to the Selected list, and then click OK.
  4. In the Add Permissions panel, view the authorization information and click Complete.

What to do next

The RAM user of Enterprise B can access Message Queue for RabbitMQ of Enterprise A by using the following methods:

  • Console
    1. Open the RAM Account Login page in your browser.
    2. On the RAM Account Login page, specify Username and click Next. Then, specify Password and click Login.
      Note The logon name of the RAM user is in the format of <$username>@<$AccountAlias> or <$username>@<$AccountAlias>.onaliyun.com. <$AccountAlias> is the account alias. If no account alias is specified, the ID of the Alibaba Cloud account is used.
    3. On the RAM user center page, move the pointer over the profile picture in the upper-right corner and click Switch Identity.
    4. On the Switch Role page, enter the enterprise alias or default domain name of Enterprise A and the RAM role name, and click Submit.
      Note
      • Enterprise alias: Use the Alibaba Cloud account of Enterprise A to log on to the Alibaba Cloud user center, move the pointer over the profile picture in the upper-right corner, and view the enterprise alias.
      • Default domain name: Use the Alibaba Cloud account of Enterprise A to log on to the RAM console. On the Settings page, click the Advanced tab to view the default domain name.
  • API operation
    1. Call the AssumeRole API operation to obtain the AccessKey ID, AccessKey secret, and a temporary security token. For more information, see AssumeRole.
    2. Use the obtained AccessKey ID, AccessKey secret, and temporary security token in code to access Message Queue for RabbitMQ.