Property

id

new InstanceGroupManager(zone, name)

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');
const instanceGroupManager = zone.instanceGroupManager('web-servers');

Parameters

Name Type Optional Description

zone

 

 

name

 

 

See also

Creating Groups of Instances

Managed Instance Groups

Property

id  string

Methods

abandonInstances(vms, callback)

Flags the specified instances to be removed from the managed instance group.

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');
const instanceGroupManager = zone.instanceGroupManager('web-servers');

const vms = [
  gce.zone('us-central1-a').vm('http-server'),
  gce.zone('us-central1-a').vm('https-server')
];

instanceGroupManager.abandonInstances(vms, function(err, operation, apiResponse) {
  // `operation` is an Operation object that can be used to check the status
  // of the request.
});

//-
// If the callback is omitted, we'll return a Promise.
//-
instanceGroupManager.abandonInstances(vms).then(function(data) {
  const operation = data[0];
  const apiResponse = data[1];
});

Parameters

Name Type Optional Description

vms

(VM or Array of VM)

 

VM instances to abandon from this instance group manager.

callback

function()

 

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

error

 

An error returned while making this request.

Value can be null.

operation

Operation

 

An operation object that can be used to check the status of the request.

apiResponse

object

 

The full API response.

See also

InstanceGroupManagers: abandonInstances API Documentation

deleteInstances(vms, callback)

Flags the specified instances in the managed instance group for immediate deletion.

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');
const instanceGroupManager = zone.instanceGroupManager('web-servers');

const vms = [
  gce.zone('us-central1-a').vm('http-server'),
  gce.zone('us-central1-a').vm('https-server')
];

instanceGroupManager.deleteInstances(vms, function(err, operation, apiResponse) {
  // `operation` is an Operation object that can be used to check the status
  // of the request.
});

//-
// If the callback is omitted, we'll return a Promise.
//-
instanceGroupManager.deleteInstances(vms).then(function(data) {
  const operation = data[0];
  const apiResponse = data[1];
});

Parameters

Name Type Optional Description

vms

(VM or Array of VM)

 

VM instances to delete from this instance group manager.

callback

function()

 

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

error

 

An error returned while making this request.

Value can be null.

operation

Operation

 

An operation object that can be used to check the status of the request.

apiResponse

object

 

The full API response.

See also

InstanceGroupManagers: deleteInstances API Documentation

exists(callback)

Check if the instance group manager exists.

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');
const instanceGroupManager = zone.instanceGroupManager('web-servers');

instanceGroupManager.exists(function(err, exists) {});

//-
// If the callback is omitted, we'll return a Promise.
//-
instanceGroupManager.exists().then(function(data) {
  const exists = data[0];
});

Parameters

Name Type Optional Description

callback

function()

 

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

error

 

An error returned while making this request.

Value can be null.

exists

boolean

 

Whether the instance group manager exists or not.

get([options])

Get an instance group manager if it exists.

You may optionally use this to "get or create" an object by providing an object with autoCreate set to true. Any extra configuration that is normally required for the create method must be contained within this object as well.

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');
const instanceGroupManager = zone.instanceGroupManager('web-servers');

instanceGroupManager.get(function(err, instanceGroupManager, apiResponse) {
  // `instanceGroupManager` is an InstanceGroupManager object.
});

//-
// If the callback is omitted, we'll return a Promise.
//-
instanceGroupManager.get().then(function(data) {
  const instanceGroupManager = data[0];
  const apiResponse = data[1];
});

Parameters

Name Type Optional Description

options

options

Yes

Configuration object.

Values in options have the following properties:

Name Type Optional Description

autoCreate

boolean

 

Automatically create the object if it does not exist. Default: false

getManagedInstances([options], callback)

Get a list of managed VM instances in this instance group manager.

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');
const instanceGroupManager = zone.instanceGroupManager('web-servers');

instanceGroupManager.getManagedInstances(function(err, vms) {
  // `vms` is an array of `VM` objects.
});

//-
// To control how many API requests are made and page through the results
// manually, set `autoPaginate` to `false`.
//-
function callback(err, vms, nextQuery, apiResponse) {
  if (nextQuery) {
    // More results exist.
    instanceGroupManager.getManagedInstances(nextQuery, callback);
  }
}

instanceGroupManager.getManagedInstances({
  autoPaginate: false
}, callback);

//-
// If the callback is omitted, we'll return a Promise.
//-
instanceGroupManager.getManagedInstances().then(function(data) {
  const vms = data[0];
});

Parameters

Name Type Optional Description

options

object

Yes

Instance search options.

Values in options have the following properties:

Name Type Optional Description

autoPaginate

boolean

 

Have pagination handled automatically. Default: true.

filter

string

 

Search filter in the format of {name} {comparison} {filterString}. - name: the name of the field to compare - comparison: the comparison operator, eq (equal) or ne (not equal) - filterString: the string to filter to. For string fields, this can be a regular expression.

maxApiCalls

number

 

Maximum number of API calls to make.

maxResults

number

 

Maximum number of VMs to return.

pageToken

string

 

A previously-returned page token representing part of the larger set of results to view.

callback

function()

 

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

error

 

An error returned while making this request.

Value can be null.

vms

Array of VM

 

VM objects from this instance group.

apiResponse

object

 

The full API response.

See also

InstanceGroupManagers: listManagedInstances API Documentation

getMetadata([callback])

Get the instance group manager's metadata.

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');
const instanceGroupManager = zone.instanceGroupManager('web-servers');

instanceGroupManager.getMetadata(function(err, metadata, apiResponse) {});

//-
// If the callback is omitted, we'll return a Promise.
//-
instanceGroupManager.getMetadata().then(function(data) {
  const metadata = data[0];
  const apiResponse = data[1];
});

Parameters

Name Type Optional Description

callback

function()

Yes

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

error

 

An error returned while making this request.

Value can be null.

metadata

object

 

The instance group manager's metadata.

apiResponse

object

 

The full API response.

See also

InstanceGroupManagers: get API Documentation

InstanceGroupManagers Resource

resize(size, callback)

Resizes the managed instance group.

Example

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const zone = compute.zone('us-central1-a');
const instanceGroupManager = zone.instanceGroupManager('web-servers');

instanceGroupManager.resize(2, function(err, operation, apiResponse) {
  // `operation` is an Operation object that can be used to check the status
  // of the request.
});

//-
// If the callback is omitted, we'll return a Promise.
//-
instanceGroupManager.resize(2).then(function(data) {
  const operation = data[0];
  const apiResponse = data[1];
});

Parameters

Name Type Optional Description

size

number

 

The number of running instances that the managed instance group should maintain at any given time.

callback

function()

 

The callback function.

Values in callback have the following properties:

Name Type Optional Description

err

error

 

An error returned while making this request.

Value can be null.

operation

Operation

 

An operation object that can be used to check the status of the request.

apiResponse

object

 

The full API response.

See also

InstanceGroupManagers: resize API Documentation