-
-
Save antonydevanchi/209f10fe443b2fcf37a6f5595cc54287 to your computer and use it in GitHub Desktop.
Yandex Cloud Cron Snapshot
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
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 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
{ | |
"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 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
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