このページは、お客様の言語ではご利用いただけません。Huawei Cloudは、より多くの言語バージョンを追加するために懸命に取り組んでいます。ご協力ありがとうございました。

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ Data Lake Insight/ Developer Guide/ Spark Jar Jobs/ Spark Jar Jobs Using DEW to Acquire Access Credentials for Reading and Writing Data from and to OBS

Spark Jar Jobs Using DEW to Acquire Access Credentials for Reading and Writing Data from and to OBS

Updated on 2025-01-10 GMT+08:00

Scenario

To write the output data of a Spark Jar job to OBS, AK/SK is required for accessing OBS. To ensure the security of AK/SK data, you can use Data Encryption Workshop (DEW) and Cloud Secret Management Service (CSMS) for unified management of AK/SK, effectively avoiding sensitive information leakage and business risks caused by hard-coded or plaintext configuration of programs.

This section walks you through on how a Spark Jar job acquires an AK/SK to read and write data from and to OBS.

Prerequisites

  • A shared secret has been created on the DEW console and the secret value has been stored. For details, see Creating a Shared Secret.
  • An agency has been created and authorized for DLI to access DEW. The agency must have been granted the following permissions:
    • Permission of the ShowSecretVersion interface for querying secret versions and secret values in DEW: csms:secretVersion:get.
    • Permission of the ListSecretVersions interface for listing secret versions in DEW: csms:secretVersion:list.
    • Permission to decrypt DEW secrets: kms:dek:decrypt

      For details about agency permission examples, see Customizing DLI Agency Permissions and Agency Permission Policies in Common Scenarios.

  • DEW can be used to manage access credentials only in Spark 3.3.1 (Spark general queue scenario) or later. When creating a Spark job, select version 3.3.1 and configure the information of the agency that allows DLI to access DEW for the job.

    For details about how to create a custom agency and configure it, see Customizing DLI Agency Permissions.

  • To use this function, you need to configure AK/SK for all OBS buckets.

Syntax

On the Spark Jar job editing page, set Runtime Configuration as needed. The configuration information is as follows:

Different OBS buckets use different AK/SK authentication information. You can use the following configuration method to specify the AK/SK information based on the bucket. For details about the parameters, see Table 1.

spark.hadoop.fs.obs.bucket.USER_BUCKET_NAME.dew.access.key= USER_AK_CSMS_KEY
spark.hadoop.fs.obs.bucket.USER_BUCKET_NAME.dew.secret.key= USER_SK_CSMS_KEY
spark.hadoop.fs.obs.security.provider = com.dli.provider.UserObsBasicCredentialProvider
spark.hadoop.fs.dew.csms.secretName= CredentialName
spark.hadoop.fs.dew.endpoint=ENDPOINT
spark.hadoop.fs.dew.csms.version=VERSION_ID
spark.hadoop.fs.dew.csms.cache.time.second =CACHE_TIME
spark.dli.job.agency.name=USER_AGENCY_NAME

Parameter Description

Table 1 Parameters

Parameter

Mandatory

Default Value

Data Type

Description

spark.hadoop.fs.obs.bucket.USER_BUCKET_NAME.dew.access.key

Yes

None

String

USER_BUCKET_NAME needs to be replaced with the user's OBS bucket name.

The value of this parameter is the key defined by the user in the CSMS shared secret. The value corresponding to the key is the user's access key ID (AK). The user must have the permission to access the bucket on OBS.

spark.hadoop.fs.obs.bucket.USER_BUCKET_NAME.dew.secret.key

Yes

None

String

USER_BUCKET_NAME needs to be replaced with the user's OBS bucket name.

The value of this parameter is the key defined by the user in the CSMS shared secret. The value corresponding to the key is the user's secret access key (SK). The user must have the permission to access the bucket on OBS.

spark.hadoop.fs.obs.security.provider

Yes

None

String

OBS AK/SK authentication mechanism, which uses DEW-CSMS' secret management to obtain the AK and SK for accessing OBS.

The default value is com.dli.provider.UserObsBasicCredentialProvider.

spark.hadoop.fs.dew.csms.secretName

Yes

None

String

Name of the shared secret in DEW's secret management.

Configuration example: spark.hadoop.fs.dew.csms.secretName=secretInfo

spark.hadoop.fs.dew.endpoint

Yes

None

String

Endpoint of the DEW service to be used.

See Regions and Endpoints.

Configuration example: spark.hadoop.fs.dew.endpoint=kms.cn-xxxx.myhuaweicloud.com

spark.hadoop.fs.dew.csms.version

No

Latest version

String

Version number (certificate version identifier) of the common credential created in DEW's credential management.

If not specified, the latest version of the common credential is obtained by default.

Configuration example: spark.hadoop.fs.dew.csms.version=v1

spark.hadoop.fs.dew.csms.cache.time.second

No

3600

Long

Cache duration after the CSMS shared secret is obtained during Spark job access.

The unit is second. The default value is 3600 seconds.

spark.hadoop.fs.dew.projectId

No

Yes

String

ID of the project DEW belongs to. The default value is the ID of the project where the Spark job is.

See Obtaining a Project ID.

spark.dli.job.agency.name

Yes

-

String

Custom agency name.

Sample Code

This section describes how to write processed DataGen data to OBS. You need to modify the parameters in the sample Java code based on site requirements.

  1. Create an agency for DLI to access DEW and complete authorization.

    For details, see Customizing DLI Agency Permissions.

  2. Create a shared secret in DEW. For details, see Creating a Shared Secret.
    1. Log in to the DEW management console.
    2. In the navigation pane on the left, choose Cloud Secret Management Service > Secrets.
    3. On the displayed page, click Create Secret. Set basic secret information.
  3. Set job parameters on the DLI Spark Jar job editing page.
    Spark Arguments
    spark.hadoop.fs.obs.bucket.USER_BUCKET_NAME.dew.access.key= USER_AK_CSMS_KEY
    spark.hadoop.fs.obs.bucket.USER_BUCKET_NAME.dew.secret.key= USER_SK_CSMS_KEY
    spark.hadoop.fs.obs.security.provider=com.dli.provider.UserObsBasicCredentialProvider
    spark.hadoop.fs.dew.csms.secretName=obsAkSk
    spark.hadoop.fs.dew.endpoint=kmsendpoint
    spark.hadoop.fs.dew.csms.version=v3
    spark.dli.job.agency.name=agency
  4. Sample Code

    For details about the sample code, see Using Spark Jar Jobs to Read and Query OBS Data.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback