2017-03-24 12 views

答えて

0

はい、クラウド機能を使用してGoogle Cloud Computeインスタンスをリセットできます。

あなたのクラウド機能を作成するためにthis linkで示す手順に従うことができますし、index.jsとpackage.jsonは以下のようになります。

index.js

package.json

exports.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コードでプロジェクト、ゾーン、インスタンスの値を変更する必要があることを認識してください。

https://cloud.google.com/functions/docs/quickstart-console

関連する問題