Google functions doesn't work turning on and off a vm instance in cloud computing

Viewed 285

I had two Google functions in Google cloud computing to turn on and off an instance. They were working until 2 weeks ago. I cannot find the issue with these functions.

I followed this Medium post https://medium.com/google-cloud/start-stop-compute-engine-instance-from-cloud-function-bf9ae5199609.

Did anything change in Google environment to not allow a cloud function to turn on and off an instance?

The code:

/**
 * Responds to any HTTP request.
 *
 * @param {!express:Request} req HTTP request context.
 * @param {!express:Response} res HTTP response context.
 */

 var http = require('http');
 var Compute = require('@google-cloud/compute');
 var compute = Compute();

exports.helloWorld = (req, res) => {
  var zone = compute.zone('europe-west2-c');    
  var vm = zone.vm('instance-4');    
  vm.start(function(err, operation, apiResponse) {        
    console.log('instance start successfully');
  });
  res.status(200).send('on');
};

And in the logs I found: Accessing deprecated metadata server endpoint at "/computeMetadata/v1beta1/instance/service-accounts/default/token" from user-agent "google-api-nodejs-client/0.10.0"

Many thanks!

0 Answers
Related