Last active
November 12, 2020 20:12
-
-
Save nikolaymatrosov/15375b1b3712eb792b4cdd16336be3b8 to your computer and use it in GitHub Desktop.
Yandex Cloud Cron Snapshot
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
import {DiskService, SnapshotService} from "yandex-cloud/api/compute/v1"; | |
const FOLDER_ID = process.env.FOLDER_ID; | |
export async function handler(event, context) { | |
const snapshotService = new SnapshotService(); | |
const diskService = new DiskService(); | |
const diskList = await diskService.list({ | |
folderId: FOLDER_ID, | |
}); | |
const snapshotOperations = []; | |
for (const disk of diskList.disks) { | |
if ('snapshot' in disk.labels) { | |
const op = snapshotService.create({ | |
folderId: FOLDER_ID, | |
diskId: disk.id | |
}); | |
snapshotOperations.push(op); | |
} | |
} | |
// await Promise.all(snapshotOperations); | |
} |
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
{ | |
"name": "functions", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"yandex-cloud": "~1.1.1" | |
} | |
} |
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
Show hidden characters
{ | |
"compilerOptions": { | |
"module": "commonjs", | |
"target": "es2018", | |
"sourceMap": true | |
}, | |
"exclude": [ | |
"node_modules" | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment