baked in cloud formation template
parent
709c102c38
commit
ff12d4e434
|
|
@ -23,7 +23,13 @@ jobs:
|
||||||
with:
|
with:
|
||||||
node-version: 12.x
|
node-version: 12.x
|
||||||
- run: yarn
|
- run: yarn
|
||||||
- run: yarn run cli -m aws-garbage-collect-all-1d-older
|
- run: yarn run cli -m aws-list-tasks
|
||||||
|
env:
|
||||||
|
AWS_REGION: eu-west-2
|
||||||
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
AWS_DEFAULT_REGION: eu-west-2
|
||||||
|
- run: yarn run cli -m aws-list-stacks
|
||||||
env:
|
env:
|
||||||
AWS_REGION: eu-west-2
|
AWS_REGION: eu-west-2
|
||||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
|
|
|
||||||
|
|
@ -2003,6 +2003,60 @@ const cli_functions_repository_1 = __nccwpck_require__(85301);
|
||||||
const input_1 = __importDefault(__nccwpck_require__(91933));
|
const input_1 = __importDefault(__nccwpck_require__(91933));
|
||||||
const cloud_runner_logger_1 = __importDefault(__nccwpck_require__(22855));
|
const cloud_runner_logger_1 = __importDefault(__nccwpck_require__(22855));
|
||||||
class AwsCliCommands {
|
class AwsCliCommands {
|
||||||
|
static awsListStacks() {
|
||||||
|
var _a;
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
process.env.AWS_REGION = input_1.default.region;
|
||||||
|
const CF = new aws_sdk_1.default.CloudFormation();
|
||||||
|
const stacks = ((_a = (yield CF.listStacks().promise()).StackSummaries) === null || _a === void 0 ? void 0 : _a.filter((_x) => _x.StackStatus !== 'DELETE_COMPLETE')) || [];
|
||||||
|
for (const element of stacks) {
|
||||||
|
cloud_runner_logger_1.default.log(JSON.stringify(element, undefined, 4));
|
||||||
|
if (element.StackName === 'game-ci' || element.TemplateDescription === 'Game-CI base stack') {
|
||||||
|
cloud_runner_logger_1.default.log(`Skipping ${element.StackName} ignore list`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
cloud_runner_logger_1.default.log(`${element.StackName}`);
|
||||||
|
}
|
||||||
|
if (stacks === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
static awsListTasks() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
process.env.AWS_REGION = input_1.default.region;
|
||||||
|
cloud_runner_logger_1.default.log(`ECS Clusters`);
|
||||||
|
const ecs = new aws_sdk_1.default.ECS();
|
||||||
|
const clusters = (yield ecs.listClusters().promise()).clusterArns || [];
|
||||||
|
for (const element of clusters) {
|
||||||
|
const input = {
|
||||||
|
cluster: element,
|
||||||
|
};
|
||||||
|
const list = (yield ecs.listTasks(input).promise()).taskArns || [];
|
||||||
|
if (list.length > 0) {
|
||||||
|
cloud_runner_logger_1.default.log(`DescribeTasksRequest`);
|
||||||
|
cloud_runner_logger_1.default.log(JSON.stringify(list, undefined, 4));
|
||||||
|
const describeInput = { tasks: list, cluster: element };
|
||||||
|
const describeList = (yield ecs.describeTasks(describeInput).promise()).tasks || [];
|
||||||
|
if (describeList === []) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (const taskElement of describeList) {
|
||||||
|
if (taskElement === undefined) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
taskElement.overrides = {};
|
||||||
|
taskElement.attachments = [];
|
||||||
|
cloud_runner_logger_1.default.log(JSON.stringify(taskElement, undefined, 4));
|
||||||
|
if (taskElement.createdAt === undefined) {
|
||||||
|
cloud_runner_logger_1.default.log(`Skipping ${taskElement.taskDefinitionArn} no createdAt date`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
static garbageCollectAws() {
|
static garbageCollectAws() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
yield AwsCliCommands.cleanup(false);
|
yield AwsCliCommands.cleanup(false);
|
||||||
|
|
@ -2077,6 +2131,12 @@ class AwsCliCommands {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
__decorate([
|
||||||
|
cli_functions_repository_1.CliFunction(`aws-list-stacks`, `List stacks`)
|
||||||
|
], AwsCliCommands, "awsListStacks", null);
|
||||||
|
__decorate([
|
||||||
|
cli_functions_repository_1.CliFunction(`aws-list-tasks`, `List tasks`)
|
||||||
|
], AwsCliCommands, "awsListTasks", null);
|
||||||
__decorate([
|
__decorate([
|
||||||
cli_functions_repository_1.CliFunction(`aws-garbage-collect`, `garbage collect aws`)
|
cli_functions_repository_1.CliFunction(`aws-garbage-collect`, `garbage collect aws`)
|
||||||
], AwsCliCommands, "garbageCollectAws", null);
|
], AwsCliCommands, "garbageCollectAws", null);
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -4,6 +4,59 @@ import Input from '../../../../input';
|
||||||
import CloudRunnerLogger from '../../../services/cloud-runner-logger';
|
import CloudRunnerLogger from '../../../services/cloud-runner-logger';
|
||||||
|
|
||||||
export class AwsCliCommands {
|
export class AwsCliCommands {
|
||||||
|
@CliFunction(`aws-list-stacks`, `List stacks`)
|
||||||
|
static async awsListStacks() {
|
||||||
|
process.env.AWS_REGION = Input.region;
|
||||||
|
const CF = new AWS.CloudFormation();
|
||||||
|
const stacks =
|
||||||
|
(await CF.listStacks().promise()).StackSummaries?.filter((_x) => _x.StackStatus !== 'DELETE_COMPLETE') || [];
|
||||||
|
for (const element of stacks) {
|
||||||
|
CloudRunnerLogger.log(JSON.stringify(element, undefined, 4));
|
||||||
|
if (element.StackName === 'game-ci' || element.TemplateDescription === 'Game-CI base stack') {
|
||||||
|
CloudRunnerLogger.log(`Skipping ${element.StackName} ignore list`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
CloudRunnerLogger.log(`${element.StackName}`);
|
||||||
|
}
|
||||||
|
if (stacks === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@CliFunction(`aws-list-tasks`, `List tasks`)
|
||||||
|
static async awsListTasks() {
|
||||||
|
process.env.AWS_REGION = Input.region;
|
||||||
|
CloudRunnerLogger.log(`ECS Clusters`);
|
||||||
|
const ecs = new AWS.ECS();
|
||||||
|
const clusters = (await ecs.listClusters().promise()).clusterArns || [];
|
||||||
|
for (const element of clusters) {
|
||||||
|
const input: AWS.ECS.ListTasksRequest = {
|
||||||
|
cluster: element,
|
||||||
|
};
|
||||||
|
const list = (await ecs.listTasks(input).promise()).taskArns || [];
|
||||||
|
if (list.length > 0) {
|
||||||
|
CloudRunnerLogger.log(`DescribeTasksRequest`);
|
||||||
|
CloudRunnerLogger.log(JSON.stringify(list, undefined, 4));
|
||||||
|
const describeInput: AWS.ECS.DescribeTasksRequest = { tasks: list, cluster: element };
|
||||||
|
const describeList = (await ecs.describeTasks(describeInput).promise()).tasks || [];
|
||||||
|
if (describeList === []) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (const taskElement of describeList) {
|
||||||
|
if (taskElement === undefined) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
taskElement.overrides = {};
|
||||||
|
taskElement.attachments = [];
|
||||||
|
CloudRunnerLogger.log(JSON.stringify(taskElement, undefined, 4));
|
||||||
|
if (taskElement.createdAt === undefined) {
|
||||||
|
CloudRunnerLogger.log(`Skipping ${taskElement.taskDefinitionArn} no createdAt date`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@CliFunction(`aws-garbage-collect`, `garbage collect aws`)
|
@CliFunction(`aws-garbage-collect`, `garbage collect aws`)
|
||||||
static async garbageCollectAws() {
|
static async garbageCollectAws() {
|
||||||
await AwsCliCommands.cleanup(false);
|
await AwsCliCommands.cleanup(false);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue