当我从Compute对象的构造函数中排除keyFilename时,我得到了所有VM的列表。
const Compute = require('@google-cloud/compute');
const compute = new Compute();
const vms = await compute.getVMs(); // populated with right results
但是,只要我在Compute对象的构造函数中指定了keyFilename,虽然它们共享了与keyFilename中指定的相同的Google Cloud Project ID,但我的所有VM都不会显示在结果中。
const Compute = require('@google-cloud/compute');
const compute = new Compute({
keyFilename: 'gcp.json'
});
const vms = await compute.getVMs(); // empty array
请帮忙!
也许最好为keyFilename使用绝对路径并添加参数
projectId: 'your-project-id'
到构造函数。
除此之外,根据documentation,你的代码看起来非常香草,所以我认为没有问题,应该工作。