Created
August 22, 2019 17:59
-
-
Save JeremyEnglert/ddf964e018b754a3480ac66211406adc to your computer and use it in GitHub Desktop.
Google Cloud Compute API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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