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

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)
Feedback