1
クラウド機能を使用してGoogle Cloud Platformで実行されているCompute Machineを再起動する必要があります。クラウド機能を使用した仮想マシンへのアクセス
クラウド機能を使用する方法はありますか?計算には残りのAPIが必要ですが、クラウド機能で動作するかどうかはわかりません。
クラウド機能を使用してGoogle Cloud Platformで実行されているCompute Machineを再起動する必要があります。クラウド機能を使用した仮想マシンへのアクセス
クラウド機能を使用する方法はありますか?計算には残りのAPIが必要ですが、クラウド機能で動作するかどうかはわかりません。
はい、クラウド機能を使用してGoogle Cloud Computeインスタンスをリセットできます。
あなたのクラウド機能を作成するためにthis linkで示す手順に従うことができますし、index.jsとpackage.jsonは以下のようになります。
index.js
package.jsonexports.resetting = function resetting() {
var google = require('googleapis');
var compute = google.compute('beta');
authorize(function(authClient) {
var request = {
// Project ID for this request.
project: 'YOUR-PROJECT-ID', // TODO: Update placeholder value.
// The name of the zone for this request.
zone: 'YOUR-INSTANCE-ZONE', // TODO: Update placeholder value.
// Name of the instance scoping this request.
instance: 'YOUR-INSTANCE-NAME', // TODO: Update placeholder value.
auth: authClient,
};
compute.instances.reset(request, function(err, response) {
if (err) {
console.error(err);
return;
}
// TODO: Change code below to process the `response` object:
console.log(JSON.stringify(response, null, 2));
});
});
function authorize(callback) {
google.auth.getApplicationDefault(function(err, authClient) {
if (err) {
console.error('authentication failed: ', err);
return;
}
if (authClient.createScopedRequired && authClient.createScopedRequired()) {
var scopes = ['https://www.googleapis.com/auth/cloud-platform'];
authClient = authClient.createScoped(scopes);
}
callback(authClient);
});
};
}
{
"name": "googleapis",
"version": "24.0.0",
"dependencies": {"googleapis":"^24.0.0"}
}
クラウド機能の作成時に表示される「実行する機能」フィールドには、使用している機能の名前を入力する必要があります。ケース "リセット"
私が提供したindex.jsコードでプロジェクト、ゾーン、インスタンスの値を変更する必要があることを認識してください。