When you ship data to MaxCompute, you must use a default or custom role to read data from the logstore. This topic describes how to authorize a default role and a custom role to read data from Simple Log Service.
Authorize the default role
Procedure
-
Log on to the Alibaba Cloud Management Console using your Alibaba Cloud account or a RAM user.
-
Click Resource Access Authorization to complete the authorization.
Note-
If the Alibaba Cloud account does not have the default role
AliyunLogDefaultRole, the role is created the first time the RAM user clicks the link. -
Simple Log Service assumes the
AliyunLogDefaultRolerole to access your resources in other cloud products. -
For details about the access policy of
AliyunLogDefaultRole, see AliyunLogDefaultRole.
-
What to do next
By default, the AliyunLogDefaultRole role has permission to read data from a logstore. When you create a MaxCompute shipping task, set Authorization to Read Simple Log Service to Default Role. For more information, see Create a MaxCompute shipping task (new version). Example role ARN: acs:ram:<account_id>:role/aliyunlogdefaultrole.
Authorize a custom role
Procedure
Authorizing a RAM role allows a MaxCompute shipping task to use that role to read data from the logstore.
-
Log on to the RAM console using your Alibaba Cloud account or as a RAM administrator.
-
Create a RAM role to be assumed by the Alibaba Cloud service. For more information, see Create a RAM role for Alibaba Cloud services.
ImportantWhen creating a RAM role, set Principal Type to Cloud Service, and Principal Name to Simple Log Service.
Check the trust policy of the RAM role. Make sure that the
Serviceelement contains at least"log.aliyuncs.com".{ "Statement": [ { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { "Service": [ "log.aliyuncs.com" ] } } ], "Version": "1" }
Create a custom policy to grant Logstore read permissions.
Grant permissions by exact match or wildcard match.
Exact match
ImportantReplace
Project nameandLogstore namein the policy document based on your business requirements."Version":"1", "Statement":[ { "Action":[ "log:GetCursorOrData", "log:ListShards" ], "Resource":[ "acs:log:*:*:project/your-project-name/logstore/your-Logstore-name" ], "Effect":"Allow" } ] }
Wildcard match
ImportantFor example, use a wildcard match to grant permissions to multiple projects and Logstores at once, such as projects named
log-project-dev-*and Logstores namedwebsite_*_log.Replace
log-project-dev-*andwebsite_*_log*in the policy with your project and Logstore name patterns.
{ "Version":"1", "Statement":[ { "Action":[ "log:GetCursorOrData", "log:ListShards" ], "Resource":[ "acs:log:*:*:project/log-project-dev-*/logstore/website_*_log*" ], "Effect":"Allow" } ] }-
Attach the created custom policy to the RAM role. For more information, see Manage permissions for a RAM role.
What to do next
After completing the authorization, you can set Authorization to Read Simple Log Service to Custom Role when you create a MaxCompute shipping task. For more information, see Create a MaxCompute shipping task (new version). Enter the role ARN in the input box. Example: acs:ram::<account_id>:role/maxcomputeshiprole.