动态发布记录(2026年)

参数 | 说明 |
Python 版本 | 支持 Python 2 和 Python 3。 |
import wedatautilssecret_name = "test_secret_name" #credential nameversion_id = "1.0" #Credential versionregion="ap-guangzhou" #The region where the certificate is locatedsecret_value = wedatautils.get_secret_value(secret_name,version_id,region) #Get credential contentprint("this is"+secret_value)

import osfrom tencentcloud.common import credentialfrom tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKExceptionfrom tencentcloud.ssm.v20190923 import ssm_client, modelsdef 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 objectcred = 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 objectreq = models.GetSecretValueRequest()# Set the credential namereq.SecretName = secret_namereq.VersionId = version_id# Send requestresp = client.GetSecretValue(req)# Output JSON format response#print(resp.to_json_string())# Return the credential valuereturn resp.SecretStringexcept TencentCloudSDKException as err:print(f"Error occurred: {err}")return None
import osfrom test_ssm import get_secret_value #test_ssm is the resource namesecret_name = "test_lola" #Credential Nameversion_id = "1.0" #Credential Versionregion="ap-singapore" #the region of Credentialsecret_value = get_secret_value(secret_name,version_id,region) #Get the credential contentprint(secret_value)##@resource_reference("test_ssm")
피드백