产品动态

exports.main_handler = async (event, context) => {// Depends on tencentcloud-sdk-nodejs version 4.0.3 or higherconst tencentcloud = require("tencentcloud-sdk-nodejs");const CvmClient = tencentcloud.cvm.v20170312.Client;const CbsClient = tencentcloud.cbs.v20170312.Client;var secretId = process.env.secretId //环境变量注入您账号的 secretIdvar secretKey = process.env.secretKey //环境变量注入您账号的 secretKeyvar insID = event.subjectconst clientConfig1 = {credential: {secretId: secretId,secretKey: secretKey,},region: "ap-guangzhou",profile: {httpProfile: {endpoint: "cvm.tencentcloudapi.com",},},};const client1 = new CvmClient(clientConfig1);const params1 = {"InstanceIds": [${替换成需要重启的实例ID}],"StopType": "SOFT"};client1.RebootInstances(params1).then((data) => {console.log(data);},(err) => {console.error("error", err);});const clientConfig2 = {credential: {secretId: secretId,secretKey: secretKey,},region: "ap-guangzhou",profile: {httpProfile: {endpoint: "cbs.tencentcloudapi.com",},},};const client2 = new CbsClient(clientConfig2);const params2 = {"DiskId": ${替换成需要备份的的硬盘ID}};client2.CreateSnapshot(params2).then((data) => {console.log(data);},(err) => {console.error("error", err);});};


{"source":"cvm.cloud.tencent","region":"ap-guangzhou"}
{"source":"cvm.cloud.tencent","subject":["ins-xxxxxx","ins-xxxxxx"]}







文档反馈