
# -*- coding: utf-8 -*-import osimport jsonimport typesfrom tencentcloud.common import credentialfrom tencentcloud.common.profile.client_profile import ClientProfilefrom tencentcloud.common.profile.http_profile import HttpProfilefrom tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKExceptionfrom tencentcloud.ssm.v20190923 import ssm_client, modelstry:# Instantiate an authentication object. The Tencent Cloud account SecretId and SecretKey must be passed in as parameters. Also, ensure the confidentiality of the key pair.# Code leakage may lead to the exposure of SecretId and SecretKey, and compromise the security of all resources under the account.# You can obtain the key from the official console at https://console.tencentcloud.com/capi.cred = credential.Credential(os.getenv("TENCENTCLOUD_SECRET_ID"), os.getenv("TENCENTCLOUD_SECRET_KEY"))# Example of using a temporary key# cred = credential.Credential("SecretId", "SecretKey", "Token")# Instantiate an http option. This is optional and can be skipped if you have no special requirements.httpProfile = HttpProfile()httpProfile.endpoint = "ssm.intl.tencentcloudapi.com"# Instantiate a client option. This is optional and can be skipped if you have no special requirements.clientProfile = ClientProfile()clientProfile.httpProfile = httpProfile# Instantiate a client object for the product you want to request. The clientProfile is optional.client = ssm_client.SsmClient(cred, "ap-hongkong", clientProfile)# Instantiate a request object. Each API corresponds to a request object.req = models.GetSecretValueRequest()params = {"SecretName": "MyAppDatabaseSecret", # Replace it with your secret name."VersionId": "SSM_Current" # Specify the specific version number.}req.from_json_string(json.dumps(params))# The returned resp is an instance of GetSecretValueResponse, corresponding to the request object.resp = client.GetSecretValue(req)# Output the response packet as a JSON-formatted string.print(resp.to_json_string())except TencentCloudSDKException as err:print(err)
피드백