Created
December 8, 2018 21:06
-
-
Save ismailbaskin/39d0dad826d908d238cc24f0285d61da to your computer and use it in GitHub Desktop.
Shutdown GCP VMs
This file contains hidden or 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
const Compute = require('@google-cloud/compute'); | |
const compute = new Compute(); | |
exports.stopPolicy = async () => { | |
const [vms] = await compute.getVMs({ | |
filter: `labels.stop-policy:workhour` | |
}); | |
await Promise.all( vms.map(vm => vm.stop()) ); | |
console.log(`${vms.length} VM(s) stopped!`) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment