You can use an Alibaba Cloud account (Alibaba Cloud Account A) to create a RAM role, specify another Alibaba Cloud account (Alibaba Cloud Account B) to assume the role, and grant the RAM role the specific permissions on Log Service resources of Alibaba Cloud Account A. Then, you can grant the AssumeRole permission to the RAM users of Alibaba Cloud Account B. Then, you can use Alibaba Cloud Account B or the specified RAM users to call a Security Token Service (STS) API operation to obtain temporary security credentials. These credentials include the AccessKey ID, AccessKey secret, and security token. This way, you can use these RAM users to call Log Service API operations and access Log Service resources.
Background information
- The user of Alibaba Cloud Account B is authorized to write data to Log Service of Alibaba Cloud Account A. In addition, the user of Alibaba Cloud Account B is authorized to use consumer groups to consume data from Log Service of Alibaba Cloud Account A.
- The specified RAM users of Alibaba Cloud Account B are authorized to write data to Log Service of Alibaba Cloud Account A. In addition, the specified RAM users are authorized to use consumer groups to consume data from Log Service of Alibaba Cloud Account A.
- The user of Alibaba Cloud Account B is authorized to call a Security Token Service (STS) API operation to obtain temporary security credentials and use the credentials to call Log Service API operations and access Log Service resources. For more information, see STS.
Overview of the authorization process
- The user of Alibaba Cloud Account B creates a RAM role, specifies Alibaba Cloud Account B to assume this role, and grants Alibaba Cloud Account B the specified permissions on Log Service resources of Alibaba Cloud Account A.
- The user of Alibaba Cloud Account B creates RAM User B1 and attaches the
AliyunSTSAssumeRoleAccess
policy to RAM User B1. This allows the user of RAM User B1 to call the STS AssumeRole API operation. - The user of RAM User B1 calls the STS AssumeRole API operation. This allows RAM User B1 to initiate Log Service API requests and manage the Log Service resources of Alibaba Cloud Account A.
Step 1: The user of Alibaba Cloud Account A creates a RAM role for Alibaba Cloud Account B
The user of Alibaba Cloud Account A creates a RAM role, specifies Alibaba Cloud Account B to assume the role, and grants the RAM role the specific permissions on Log Service resources of Alibaba Cloud Account A.
You can create a RAM role in the RAM console. For more information, see Create a RAM user and authorize the RAM user to access Log Service. You can also call the CreateRole API operation to create a RAM role. For more information, see CreateRole. The following example shows how to create a RAM user in the console.
- Log on to the RAM console by using Alibaba Cloud Account A.
- Create a RAM role and specify Alibaba Cloud Account B to assume the RAM role.
- Create a permission policy.
- Use Alibaba Cloud Account A to authorize the RAM role.
- In the left-side navigation pane, click RAM Roles.
- On the RAM Roles page, find the target RAM role in the RAM Role Name column, and then click Add Permissions in the Actions column.
- On the Add Permissions page, select Custom Policy for the Select Policy field, select the policy that you create in Step 3, and then click OK.
- Click Complete.
Step 2: The user of Alibaba Cloud Account B creates RAM User B1 and grants permissions to RAM User B1
The user of Alibaba Cloud Account B creates RAM User B1 and attaches the AliyunSTSAssumeRoleAccess
policy to RAM User B1. This allows RAM User B1 to call the STS AssumeRole API operation.
Step 3: The user of RAM User B1 obtains STS temporary security credentials to access Log Service resources
Sample code
The sample code is written in the Java programming language. The user of Alibaba Cloud Account B can use STS to write data to a project of Alibaba Cloud Account A. To download the sample code, click Sample code.