E-MapReduce (EMR) allows you to configure a custom ECS application role in the Advanced Settings section of the Basic Settings step when you create a cluster in the EMR console. You can use this role to access other cloud resources, such as Object Storage Service (OSS) and Log Service, in your Alibaba Cloud account in password-free mode. This topic describes how to create and use a custom ECS application role.
Background information
- A cluster can access only the OSS data directories that you specify.
- A cluster can access the external resources that you specify.
Prerequisites
Create an OSS bucket in the OSS console. The bucket must be in the same region as your E-MapReduce cluster. For more information, see Create buckets.
Procedure
Step 1: Create a policy
-
Go to the custom policy creation page.
-
Log on to the RAM console with your Alibaba Cloud account.
-
In the left-side navigation pane, choose .
-
On the Policies page, click Create Policy.
-
-
On the Create Policy page, click the JSON tab.
-
Enter the policy content and click OK.
Add the following policy.
{ "Version": "1", "Statement": [ { "Action": [ "oss:GetObject", "oss:ListObjects" ], "Resource": [ "acs:oss:*:*:emr-logs2", "acs:oss:*:*:emr-logs2/*" ], "Effect": "Allow" } ] }NoteThe policy includes the following elements:
-
Action: the operation on a resource. In this example, permissions to read objects and list directories in OSS.
-
Resource: the authorized object. In this example, the OSS bucket named emr-logs2 and all objects within it.
For more information about the basic elements of a policy, see policy elements.
-
-
Enter a Name for the policy.
This example uses test-emr.
-
Click OK.
Step 2: Create a RAM role
-
In the left-side navigation pane of the RAM console, choose .
-
On the Role page, click Create Role.
-
Create the RAM role.
-
Select Alibaba Cloud Service.
-
Click Next.
-
In the Configure Role panel, configure the following parameters.
Parameter
Description
Role Name
This example uses test-emr.
Select Trusted Service
Select Elastic Compute Service.
-
Click Complete.
-
-
Optional: Modify the trusted service.
ImportantYou can skip this step if your cluster runs EMR 3.32 or later, EMR 4.5 or later, or EMR 5.x or later.
-
On the Role page, click the Role Name that you just created.
-
Click the trust policy tab.
-
Click Edit trust policy.
-
Change
ecs.aliyuncs.comtoemr.aliyuncs.com.
-
Click Save trust policy.
-
-
Attach the custom policy.
-
On the Role page, click Add Authorization in the Actions column for the Role Name that you just created.
-
On the Add Authorization page, select Custom Policies and attach the policy you created.
-
Click OK.
-
Click Close.
-
Step 3: Create a cluster and access external resources
-
In the top navigation bar, select a region and a resource group as needed.
-
Click CREATE_CLUSTER. On the Basic Configuration page, in the Advanced Settings section, add the name of the RAM role you created in Step 2: Create a RAM role. For more information, see Create a cluster.

-
After the cluster is created, log on to the cluster via SSH. For more information, see Log on to a cluster.
Run the following command to verify authorization.
hdfs dfs -ls oss://<yourBucketName>/NoteReplace <yourBucketName> with the name of your OSS bucket.
-
If the role does not have the required permissions, access to the OSS path fails.
-
If the role has the required permissions, you can access the OSS path.
-
FAQ
- Q: What do I do if the NoPermission message appears when I create a cluster? A: Perform the following operations in sequence to resolve the issue:
- Check whether the RAM user that you used to create the cluster is authorized to create clusters and change ECS application roles. If the RAM user is granted the AliyunEMRDevelopAccess permission, you must change the permission to AliyunEMRFullAccess.
- Check whether the name of the ECS application role that you specified when you create the cluster is valid.
- Check whether the trust policy is changed to emr.aliyuncs.com.
-
Q: Why can't HDFS access an OSS path?
A: Troubleshoot as follows:
-
Verify that the OSS bucket and the cluster are in the same region. If they are in different regions, you must add the corresponding endpoint to the access path.
-
Verify that the OSS bucket is included as a resource in the policy you created. If not, modify the policy to include it.
-
Check whether permissions for the bucket are configured in the OSS console. If so, remove them and manage permissions through the Action element in your RAM policy instead.
-