Skip to content

Instantly share code, notes, and snippets.

@JeremyEnglert
Created August 22, 2019 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeremyEnglert/ddf964e018b754a3480ac66211406adc to your computer and use it in GitHub Desktop.
Save JeremyEnglert/ddf964e018b754a3480ac66211406adc to your computer and use it in GitHub Desktop.
Google Cloud Compute API
// 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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment