@google-cloud/compute

The default export of the @google-cloud/compute package is the Compute class.

See Compute and ClientConfig for client methods and configuration options.

Examples

Install the client library with npm:

npm install --save @google-cloud/compute

Import the client library

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

Create a client that uses Application Default Credentials (ADC):

const compute = new Compute();

Create a client with explicit credentials:

const compute = new Compute({
  projectId: 'your-project-id',
  keyFilename: '/path/to/keyfile.json'
});

Full quickstart example:

  // Imports the Google Cloud client library
  const Compute = require('@google-cloud/compute');

  // Creates a client
  const compute = new Compute();

  async function quickstart() {
    // Create a new VM using the latest OS image of your choice.
    const zone = compute.zone('us-central1-c');

    // TODO(developer): choose a name for the VM
    // const vmName = 'vm-name';

    // Start the VM create task
    const [vm, operation] = await zone.createVM(vmName, {os: 'ubuntu'});
    console.log(vm);

    // `operation` lets you check the status of long-running tasks.
    await operation.promise();

    // Complete!
    console.log('Virtual machine created!');
  }
  quickstart();

Members

Firewall

Reference to the Firewall class.

See:

HealthCheck

Reference to the HealthCheck class.

See:

Image

Reference to the Image class.

See:

Network

Reference to the Network class.

See:

Operation

Reference to the Operation class.

See:

Project

Reference to the Project class.

See:

Region

Reference to the Region class.

See:

Rule

Reference to the Rule class.

See:

Service

Reference to the Service class.

See:

Snapshot

Reference to the Snapshot class.

See:

Zone

Reference to the Zone class.

See: