tencent cloud

Tencent Cloud WeData

Release Notes
Dynamic Release Record (2026)
Product Introduction
Product Overview
Product Advantages
Product Architecture
Product Features
Application Scenarios
Purchase Guide
Billing Overview
Product Version Purchase Instructions
Execute Resource Purchase Description
Billing Modes
Overdue Policy
Refund
Preparations
Overview of Account and Permission Management
Add allowlist /security groups (Optional)
Sign in to WeData with Microsoft Entra ID (Azure AD) Single Sign-On (SSO)
Operation Guide
Console Operation
Project Management
Data Integration
Studio
Data Development
Data Analysis
Data Science
Data Governance (with Unity Semantics)
API Documentation
History
Introduction
API Category
Making API Requests
Smart Ops Related Interfaces
Project Management APIs
Resource Group APIs
Data Development APIs
Data Asset - Data Dictionary APIs
Data Development APIs
Ops Center APIs
Data Operations Related Interfaces
Data Exploration APIs
Asset APIs
Metadata Related Interfaces
Task Operations APIs
Data Security APIs
Instance Operation and Maintenance Related Interfaces
Data Map and Data Dictionary APIs
Data Quality Related Interfaces
DataInLong APIs
Platform Management APIs
Data Source Management APIs
Data Quality APIs
Platform Management APIs
Asset Data APIs
Data Source Management APIs
Data Types
Error Codes
WeData API 2025-08-06
Service Level Agreements
Related Agreement
Privacy Policy
Data Processing And Security Agreement
Contact Us
Glossary

Python

PDF
Focus Mode
Font Size
Last updated: 2026-02-05 15:48:04

Feature Description

Edit Python code on node, and support submitting commands to WeData's Workflow Scheduling System for scheduling execution.

Parameter Description
Parameter
Description
Python version
Support Python 2 and Python 3.

Non-Use of secret_id & secret_key to Obtain SSM Credential Content

Use Cases

Hope to hide secret_id and secret_key, and also obtain the secret value stored in SSM.

Usage Method 1

The system has built-in functions to retrieve secret_value, which can be directly used in Python Task. The following is an example.
Use parameters of wedatautils.get_secret_value, the print result will be encrypted.
import wedatautils
secret_name = "test_secret_name" #credential name
version_id = "1.0" #Credential version
region="ap-guangzhou" #The region where the certificate is located
secret_value = wedatautils.get_secret_value(secret_name,version_id,region) #Get credential content
print("this is"+secret_value)

Usage Method 2

Step 1: Install the Required Python Package on the Resource Group

1. Enter Project Management > Project Execution Resource Group > Scheduling Resource Group, select a scheduling resource group and click the name to enter the details page.
2. On the resource group operation and maintenance interface, create an installation package command, select the following two installation packages that need to be installed, and click OK.
3. In the list operation column of the installation command, click Run, refresh to check the status. If the status is running successfully, it indicates successful installation.
tencentcloud-sdk-python-common
tencentcloud-sdk-python-ssm


Step 2: Configure the Resource File

1. Enter Offline Development > Resource Management, after creating a resource and uploading the resource file, click Confirm.
2. Create a resource using a local .py file. For example, the resource name is test_ssm, and the resource content is as follows.
import os
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.ssm.v20190923 import ssm_client, models


def get_secret_value(secret_name, version_id, region):
try:
secret_id = os.environ.get('dynamic_secret_id', '')
secret_key = os.environ.get('dynamic_secret_key', '')
dynamic_token = os.environ.get('dynamic_token', '')

# Initialize a credential object
cred = credential.Credential(secret_id, secret_key,dynamic_token)


# Initialize the client object for the product (ssm)
client = ssm_client.SsmClient(cred, region)
# Initialize a request object
req = models.GetSecretValueRequest()
# Set the credential name
req.SecretName = secret_name
req.VersionId = version_id
# Send request
resp = client.GetSecretValue(req)
# Output JSON format response
#print(resp.to_json_string())
# Return the credential value
return resp.SecretString
except TencentCloudSDKException as err:
print(f"Error occurred: {err}")
return None

Step 3: Obtain SSM Credential Content in Python Task

Reference the resource in Python tasks.
The way to obtain credential content in Python task code, with sample code as follows:
import os
from test_ssm import get_secret_value #test_ssm is the resource name

secret_name = "test_lola" #Credential Name
version_id = "1.0" #Credential Version
region="ap-singapore" #the region of Credential
secret_value = get_secret_value(secret_name,version_id,region) #Get the credential content
print(secret_value)
##@resource_reference("test_ssm")


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback