GitHub(nextgroup2706/ken_nogi)は今後使わず自社Gitea運用に切替え。 NodeSrvは旧リポジトリの履歴を破棄しファイルのみ統合(Dokploy用サービスアカウントは 別途mygit-admin/NodeSrv.gitに履歴あり)。notepmエクスポート(12GB)とPleasanter インストーラzip(208MB)はサイズが大きいため.gitignoreで除外。 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
102 lines
3.0 KiB
JavaScript
102 lines
3.0 KiB
JavaScript
const {
|
|
LightsailClient,
|
|
GetInstancesCommand,
|
|
GetInstanceCommand,
|
|
StartInstanceCommand,
|
|
StopInstanceCommand,
|
|
RebootInstanceCommand,
|
|
CreateInstancesCommand,
|
|
DeleteInstanceCommand,
|
|
CreateInstanceSnapshotCommand,
|
|
GetInstanceSnapshotsCommand,
|
|
DeleteInstanceSnapshotCommand,
|
|
} = require('@aws-sdk/client-lightsail');
|
|
|
|
function getConfig() {
|
|
const region = process.env.AWS_REGION;
|
|
const accessKeyId = process.env.AWS_ACCESS_KEY_ID;
|
|
const secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY;
|
|
if (!region || !accessKeyId || !secretAccessKey) {
|
|
throw new Error('AWS_REGION / AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY が設定されていません');
|
|
}
|
|
return { region, accessKeyId, secretAccessKey };
|
|
}
|
|
|
|
function getClient() {
|
|
const { region, accessKeyId, secretAccessKey } = getConfig();
|
|
return new LightsailClient({ region, credentials: { accessKeyId, secretAccessKey } });
|
|
}
|
|
|
|
async function listInstances(client = getClient()) {
|
|
const res = await client.send(new GetInstancesCommand({}));
|
|
return res.instances;
|
|
}
|
|
|
|
async function getInstance(instanceName, client = getClient()) {
|
|
const res = await client.send(new GetInstanceCommand({ instanceName }));
|
|
return res.instance;
|
|
}
|
|
|
|
async function startInstance(instanceName, client = getClient()) {
|
|
const res = await client.send(new StartInstanceCommand({ instanceName }));
|
|
return res.operations;
|
|
}
|
|
|
|
async function stopInstance(instanceName, client = getClient()) {
|
|
const res = await client.send(new StopInstanceCommand({ instanceName }));
|
|
return res.operations;
|
|
}
|
|
|
|
async function rebootInstance(instanceName, client = getClient()) {
|
|
const res = await client.send(new RebootInstanceCommand({ instanceName }));
|
|
return res.operations;
|
|
}
|
|
|
|
async function createInstance({ instanceName, availabilityZone, blueprintId, bundleId }, client = getClient()) {
|
|
const res = await client.send(new CreateInstancesCommand({
|
|
instanceNames: [instanceName],
|
|
availabilityZone,
|
|
blueprintId,
|
|
bundleId,
|
|
}));
|
|
return res.operations;
|
|
}
|
|
|
|
async function deleteInstance(instanceName, client = getClient()) {
|
|
const res = await client.send(new DeleteInstanceCommand({ instanceName }));
|
|
return res.operations;
|
|
}
|
|
|
|
async function createSnapshot(instanceName, snapshotName, client = getClient()) {
|
|
const res = await client.send(new CreateInstanceSnapshotCommand({
|
|
instanceSnapshotName: snapshotName,
|
|
instanceName,
|
|
}));
|
|
return res.operations;
|
|
}
|
|
|
|
async function listSnapshots(client = getClient()) {
|
|
const res = await client.send(new GetInstanceSnapshotsCommand({}));
|
|
return res.instanceSnapshots;
|
|
}
|
|
|
|
async function deleteSnapshot(snapshotName, client = getClient()) {
|
|
const res = await client.send(new DeleteInstanceSnapshotCommand({ instanceSnapshotName: snapshotName }));
|
|
return res.operations;
|
|
}
|
|
|
|
module.exports = {
|
|
getConfig,
|
|
getClient,
|
|
listInstances,
|
|
getInstance,
|
|
startInstance,
|
|
stopInstance,
|
|
rebootInstance,
|
|
createInstance,
|
|
deleteInstance,
|
|
createSnapshot,
|
|
listSnapshots,
|
|
deleteSnapshot,
|
|
};
|