我想要做的是执行用Node.js编写的云函数,并在GCE中创建vm实例。
我已经在GCE中实现了云函数来创建vm实例。我多次尝试执行云函数,但没有创建vm实例。
云函数运行时: Node.js 8
源代码如下所示。index.js
const Compute = require('@google-cloud/compute');
const compute = new Compute();
exports.startInstance = function startInstance(req, res) {
const zone = compute.zone('us-central1-c');
zone.createVM("test", {os: 'ubuntu'});
console.log('instance start successfully');
res.status(200).send('Success start instance');
};package.json
{
"name": "startInstance",
"version": "1.0.0",
"description": "create gce instance",
"main": "index.js",
"dependencies": {
"@google-cloud/compute": "1.0.0"
}
}错误有时会出现如下所示。
"textPayload": "Error: Could not refresh access token: Unsuccessful response status code. Request failed with status code 500\n at Gaxios.request (/srv/node_modules/gaxios/build/src/gaxios.js:70:23)\n at <anonymous>\n at process._tickDomainCallback (internal/process/next_tick.js:229:7)",
"insertId": "000000-58d51a97-122c-4531-9c9a-00b19695e93d",
"resource": {
"type": "cloud_function",
"labels": {
"project_id": "$project_id",
"region": "asia-northeast1",
"function_name": "function-2"
}
},
"timestamp": "2019-07-25T12:44:02.802Z",
"severity": "ERROR",
"labels": {
"execution_id": "jjcat6rtw49n"
},
"logName": "projects/$project_id/logs/cloudfunctions.googleapis.com%2Fcloud-functions",
"trace": "projects/$project_id/traces/be422ca287727cdf58d8275925c176ab",
"receiveTimestamp": "2019-07-25T12:44:08.781094017Z"
}您能告诉我为什么在GCE中没有创建vm实例吗?
发布于 2019-07-25 21:06:48
我将你的代码按原样重新生成,我得到了错误:
错误:字段‘zone’的值无效:‘us-cental1’。未知区
例如,我更新了您的代码以使用‘us-cental1-c’区域,它成功地创建了VM。
https://stackoverflow.com/questions/57201036
复制相似问题