exports.main_handler = async (event, context) => {
const tencentcloud = require("tencentcloud-sdk-nodejs");
const CvmClient = tencentcloud.cvm.v20170312.Client;
const CbsClient = tencentcloud.cbs.v20170312.Client;
var secretId = process.env.secretId
var secretKey = process.env.secretKey
var insID = event.subject
const 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);
}
);
};
本页内容是否解决了您的问题?