DataWorks Shell nodes, including common Shell nodes and EMR Shell nodes, natively integrate ossutil, letting you perform tasks such as file uploads, downloads, batch operations, and bucket management. This topic describes how to use the ossutil command-line tool in Shell and EMR Shell nodes to access OSS.
Overview
DataWorks Shell nodes, including common Shell nodes and EMR Shell nodes, natively integrate the Alibaba Cloud Object Storage Service (OSS) command-line tool, ossutil. You can configure ossutil to access OSS by providing credentials in a configuration file or as command-line parameters. For more information about how to configure ossutil, see Configure ossutil.
The ossutil command-line tool is pre-installed in the DataWorks environment. The default path is /home/admin/usertools/tools/ossutil64. You can run the ls -l /home/admin/usertools/tools/ command to view the list of tools in this directory and confirm that ossutil64 exists. The following figure shows an example of the output.

The following sections use a Shell node as an example to describe the two configuration methods.
Using command-line parameters
-
In the Shell node, edit the node content. The following sample code uses
ossutilto connect to a specified OSS endpoint and lists all buckets the current account can access./home/admin/usertools/tools/ossutil64 -e <OSSEndPoint> -i <AccessKeyID> -k <AccessKeySecret> ls -s if [[ $? == 0 ]];then echo "access oss success" else echo "failed" exit 1 fi echo "finished"NoteYou must replace the
OSSEndPoint,AccessKeyID, andAccessKeySecretplaceholders with your actual values. For more information about the parameters, see Configure ossutil.ImportantPassing an access key via command-line parameters exposes the key, creating a security risk.
-
Verify the result.
Click the
icon, select a serverless resource group, and then run the common Shell node task.
Using a configuration file
-
Create an ossutil configuration file and upload it to OSS.
-
Create a configuration file.
Create a file named
myconfig.txton your local machine. The following sample code shows the file content:[Credentials] language = CH endpoint = <Endpoint> # For example, oss-cn-shanghai.aliyuncs.com accessKeyID = <AccessKeyID> accessKeySecret = <AccessKeySecret>NoteReplace the
Endpoint,AccessKeyID, andAccessKeySecretplaceholders with your actual Alibaba Cloud OSS endpoint and the access key of a RAM user with the necessary permissions. Note: Do not enclose the parameter values in quotation marks. For more information about the parameters, see Configure ossutil. -
Upload the configuration file.
Upload the
myconfig.txtfile to OSS. For more information, see Simple upload. -
Obtain the download URL.
In the Operation column of the uploaded object, click Details. In the panel that appears, turn off Use HTTPS and then click Copy Object URL.
-
-
Download the configuration file to a serverless resource group.
On the Image Management page of the DataWorks console, create a custom image to download the configuration file to a serverless resource group.
-
Create an image.
Log on to the DataWorks console and switch to the target region. In the left-side navigation pane, click Image Management. On the Image Management page, click the Custom Image tab, and then click Create Image. In the panel that appears, configure the parameters as follows:
Parameter
Example value
Image Name
Enter a custom name for the image.
Image description
Enter a custom description for the image.
Reference type
DataWorks official image (default).
Image namespace
DataWorks default (default).
Image repository
DataWorks default (default).
Image name/ID
Select
dataworks_shell_task_pod:xxx. This is the official DataWorks image for Shell nodes.Visibility Scope
Select a scope based on your needs:
-
Visible only to creator
-
Visible to all
Module
Data Development (default).
Supported task type
Shell (default).
Installation package
From the Installation package drop-down list, select
Script. Then, enter the following command in the command box:# Download wget 'http://<yourConfigURL>' -O /home/admin/usertools/tools/<configName>Note-
Replace
http://<yourConfigURL>with the object URL you copied from the OSS details panel. -
Set
<configName>to the name of the file to download from OSS, such asmyconfig.txt.
Click OK to create the image.
-
-
Test and publish the image.
Click Deploy in the Operation column for the image you created. On the Publish Image page, select Test Resource Group, and click Test to the right of Test Result. After the Succeeded. message is displayed, click the Deploy button at the bottom.
-
In the Actions column for the published custom image, click the
icon and select Change Workspace. Bind the image to the target workspace.
-
-
Use the ossutil command-line tool with the configuration file.
-
Create a common Shell node.
-
Go to the Data Development page.
Log on to the DataWorks console, switch to the target region, and then choose Data Development and O&M > Data Studio in the left-side navigation pane. From the drop-down list, select the target workspace and click Go to DataStudio.
-
Create a common Shell node.
On the Data Development page, right-click the target business process, choose Create Node, and select Shell under the General directory.
-
-
In the Shell node, edit the node content. The following sample code uses
ossutilto connect to the OSS endpoint specified inmyconfig.txtand lists all buckets that the account specified inmyconfig.txtcan access./home/admin/usertools/tools/ossutil64 -c /home/admin/usertools/tools/myconfig.txt ls -s -
Click the
icon, select the serverless resource group you used for testing, specify the custom image you created and published, and then run the common Shell node task. -
On the Scheduling tab of the node, select the target resource group in the Resource Group section, specify the custom image that you created and published, save the scheduling configuration, commit the Shell node to the development environment, and then publish it to production.
-
Related documents
In the new version of Data Development, you can bind a RAM role to a Shell node and use STS to dynamically obtain temporary security credentials to securely access OSS by using ossutil. For more information, see Associate roles: Securely access other cloud resources.