fix age calculations
parent
ebca70b530
commit
388a42d514
|
|
@ -1984,9 +1984,9 @@ const base_stack_formation_1 = __nccwpck_require__(29643);
|
||||||
class AwsCliCommands {
|
class AwsCliCommands {
|
||||||
static awsListAll() {
|
static awsListAll() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
yield AwsCliCommands.awsListStacks(undefined, true);
|
yield AwsCliCommands.awsListStacks();
|
||||||
yield AwsCliCommands.awsListTasks();
|
yield AwsCliCommands.awsListTasks();
|
||||||
yield AwsCliCommands.awsListLogGroups(undefined, true);
|
yield AwsCliCommands.awsListLogGroups();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static garbageCollectAws() {
|
static garbageCollectAws() {
|
||||||
|
|
@ -2008,7 +2008,7 @@ class AwsCliCommands {
|
||||||
const ageDate = new Date(date.getTime() - Date.now());
|
const ageDate = new Date(date.getTime() - Date.now());
|
||||||
return ageDate.getDay() > 0;
|
return ageDate.getDay() > 0;
|
||||||
}
|
}
|
||||||
static awsListStacks(perResultCallback = false, verbose = false) {
|
static awsListStacks(perResultCallback = false) {
|
||||||
var _a, _b;
|
var _a, _b;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
process.env.AWS_REGION = input_1.default.region;
|
process.env.AWS_REGION = input_1.default.region;
|
||||||
|
|
@ -2016,18 +2016,18 @@ class AwsCliCommands {
|
||||||
const stacks = ((_a = (yield CF.listStacks().promise()).StackSummaries) === null || _a === void 0 ? void 0 : _a.filter((_x) => _x.StackStatus !== 'DELETE_COMPLETE')) || [];
|
const stacks = ((_a = (yield CF.listStacks().promise()).StackSummaries) === null || _a === void 0 ? void 0 : _a.filter((_x) => _x.StackStatus !== 'DELETE_COMPLETE')) || [];
|
||||||
cloud_runner_logger_1.default.log(`Stacks ${stacks.length}`);
|
cloud_runner_logger_1.default.log(`Stacks ${stacks.length}`);
|
||||||
for (const element of stacks) {
|
for (const element of stacks) {
|
||||||
const ageDate = new Date(element.CreationTime.getTime() - Date.now());
|
const ageDate = new Date(Date.now() - element.CreationTime.getTime());
|
||||||
if (verbose)
|
// if (verbose)
|
||||||
cloud_runner_logger_1.default.log(`Task Stack ${element.StackName} - Age D${ageDate.getDay()} H${ageDate.getHours()} M${ageDate.getMinutes()}`);
|
cloud_runner_logger_1.default.log(`Task Stack ${element.StackName} - Age D${Math.floor(ageDate.getHours() / 24)} H${ageDate.getHours()} M${ageDate.getMinutes()}`);
|
||||||
if (perResultCallback)
|
if (perResultCallback)
|
||||||
yield perResultCallback(element);
|
yield perResultCallback(element);
|
||||||
}
|
}
|
||||||
const baseStacks = ((_b = (yield CF.listStacks().promise()).StackSummaries) === null || _b === void 0 ? void 0 : _b.filter((_x) => _x.StackStatus !== 'DELETE_COMPLETE' && _x.TemplateDescription === base_stack_formation_1.BaseStackFormation.baseStackDecription)) || [];
|
const baseStacks = ((_b = (yield CF.listStacks().promise()).StackSummaries) === null || _b === void 0 ? void 0 : _b.filter((_x) => _x.StackStatus !== 'DELETE_COMPLETE' && _x.TemplateDescription === base_stack_formation_1.BaseStackFormation.baseStackDecription)) || [];
|
||||||
cloud_runner_logger_1.default.log(`Base Stacks ${baseStacks.length}`);
|
cloud_runner_logger_1.default.log(`Base Stacks ${baseStacks.length}`);
|
||||||
for (const element of baseStacks) {
|
for (const element of baseStacks) {
|
||||||
const ageDate = new Date(element.CreationTime.getTime() - Date.now());
|
const ageDate = new Date(Date.now() - element.CreationTime.getTime());
|
||||||
if (verbose)
|
// if (verbose)
|
||||||
cloud_runner_logger_1.default.log(`Base Stack ${element.StackName} - Age D${ageDate.getHours()} H${ageDate.getHours()} M${ageDate.getMinutes()}`);
|
cloud_runner_logger_1.default.log(`Task Stack ${element.StackName} - Age D${Math.floor(ageDate.getHours() / 24)} H${ageDate.getHours()} M${ageDate.getMinutes()}`);
|
||||||
if (perResultCallback)
|
if (perResultCallback)
|
||||||
yield perResultCallback(element);
|
yield perResultCallback(element);
|
||||||
}
|
}
|
||||||
|
|
@ -2071,7 +2071,7 @@ class AwsCliCommands {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static awsListLogGroups(perResultCallback = false, verbose = false) {
|
static awsListLogGroups(perResultCallback = false) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
process.env.AWS_REGION = input_1.default.region;
|
process.env.AWS_REGION = input_1.default.region;
|
||||||
const ecs = new aws_sdk_1.default.CloudWatchLogs();
|
const ecs = new aws_sdk_1.default.CloudWatchLogs();
|
||||||
|
|
@ -2091,15 +2091,15 @@ class AwsCliCommands {
|
||||||
cloud_runner_logger_1.default.log(`Skipping ${element.logGroupName} no createdAt date`);
|
cloud_runner_logger_1.default.log(`Skipping ${element.logGroupName} no createdAt date`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const ageDate = new Date(new Date(element.creationTime).getTime() - Date.now());
|
const ageDate = new Date(Date.now() - element.creationTime);
|
||||||
if (verbose)
|
// if (verbose)
|
||||||
cloud_runner_logger_1.default.log(`Log Group Name ${element.logGroupName} - Age D${ageDate.getDay()} H${ageDate.getHours()} M${ageDate.getMinutes()} - 1d old ${AwsCliCommands.isOlderThan1day(new Date(element.creationTime))}`);
|
cloud_runner_logger_1.default.log(`Task Stack ${element.logGroupName} - Age D${Math.floor(ageDate.getHours() / 24)} H${ageDate.getHours()} M${ageDate.getMinutes()}`);
|
||||||
if (perResultCallback)
|
if (perResultCallback)
|
||||||
yield perResultCallback(element, element);
|
yield perResultCallback(element, element);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static awsListJobs(perResultCallback = false, verbose = false) {
|
static awsListJobs(perResultCallback = false) {
|
||||||
var _a;
|
var _a;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
process.env.AWS_REGION = input_1.default.region;
|
process.env.AWS_REGION = input_1.default.region;
|
||||||
|
|
@ -2107,9 +2107,9 @@ class AwsCliCommands {
|
||||||
const stacks = ((_a = (yield CF.listStacks().promise()).StackSummaries) === null || _a === void 0 ? void 0 : _a.filter((_x) => _x.StackStatus !== 'DELETE_COMPLETE' && _x.TemplateDescription !== base_stack_formation_1.BaseStackFormation.baseStackDecription)) || [];
|
const stacks = ((_a = (yield CF.listStacks().promise()).StackSummaries) === null || _a === void 0 ? void 0 : _a.filter((_x) => _x.StackStatus !== 'DELETE_COMPLETE' && _x.TemplateDescription !== base_stack_formation_1.BaseStackFormation.baseStackDecription)) || [];
|
||||||
cloud_runner_logger_1.default.log(`Stacks ${stacks.length}`);
|
cloud_runner_logger_1.default.log(`Stacks ${stacks.length}`);
|
||||||
for (const element of stacks) {
|
for (const element of stacks) {
|
||||||
const ageDate = new Date(element.CreationTime.getTime() - Date.now());
|
const ageDate = new Date(Date.now() - element.CreationTime.getTime());
|
||||||
if (verbose)
|
// if (verbose)
|
||||||
cloud_runner_logger_1.default.log(`Task Stack ${element.StackName} - Age D${ageDate.getDay()} H${ageDate.getHours()} M${ageDate.getMinutes()}`);
|
cloud_runner_logger_1.default.log(`Task Stack ${element.StackName} - Age D${Math.floor(ageDate.getHours() / 24)} H${ageDate.getHours()} M${ageDate.getMinutes()}`);
|
||||||
if (perResultCallback)
|
if (perResultCallback)
|
||||||
yield perResultCallback(element);
|
yield perResultCallback(element);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -7,9 +7,9 @@ import { BaseStackFormation } from '../cloud-formations/base-stack-formation';
|
||||||
export class AwsCliCommands {
|
export class AwsCliCommands {
|
||||||
@CliFunction(`aws-list-all`, `List all resources`)
|
@CliFunction(`aws-list-all`, `List all resources`)
|
||||||
static async awsListAll() {
|
static async awsListAll() {
|
||||||
await AwsCliCommands.awsListStacks(undefined, true);
|
await AwsCliCommands.awsListStacks();
|
||||||
await AwsCliCommands.awsListTasks();
|
await AwsCliCommands.awsListTasks();
|
||||||
await AwsCliCommands.awsListLogGroups(undefined, true);
|
await AwsCliCommands.awsListLogGroups();
|
||||||
}
|
}
|
||||||
@CliFunction(`aws-garbage-collect-list`, `garbage collect aws resources not in use !WIP!`)
|
@CliFunction(`aws-garbage-collect-list`, `garbage collect aws resources not in use !WIP!`)
|
||||||
static async garbageCollectAws() {
|
static async garbageCollectAws() {
|
||||||
|
|
@ -32,7 +32,7 @@ export class AwsCliCommands {
|
||||||
return ageDate.getDay() > 0;
|
return ageDate.getDay() > 0;
|
||||||
}
|
}
|
||||||
@CliFunction(`aws-list-stacks`, `List stacks`)
|
@CliFunction(`aws-list-stacks`, `List stacks`)
|
||||||
static async awsListStacks(perResultCallback: any = false, verbose: boolean = false) {
|
static async awsListStacks(perResultCallback: any = false) {
|
||||||
process.env.AWS_REGION = Input.region;
|
process.env.AWS_REGION = Input.region;
|
||||||
const CF = new AWS.CloudFormation();
|
const CF = new AWS.CloudFormation();
|
||||||
const stacks =
|
const stacks =
|
||||||
|
|
@ -42,11 +42,14 @@ export class AwsCliCommands {
|
||||||
) || [];
|
) || [];
|
||||||
CloudRunnerLogger.log(`Stacks ${stacks.length}`);
|
CloudRunnerLogger.log(`Stacks ${stacks.length}`);
|
||||||
for (const element of stacks) {
|
for (const element of stacks) {
|
||||||
const ageDate = new Date(element.CreationTime.getTime() - Date.now());
|
const ageDate: Date = new Date(Date.now() - element.CreationTime.getTime());
|
||||||
if (verbose)
|
|
||||||
CloudRunnerLogger.log(
|
// if (verbose)
|
||||||
`Task Stack ${element.StackName} - Age D${ageDate.getDay()} H${ageDate.getHours()} M${ageDate.getMinutes()}`,
|
CloudRunnerLogger.log(
|
||||||
);
|
`Task Stack ${element.StackName} - Age D${Math.floor(
|
||||||
|
ageDate.getHours() / 24,
|
||||||
|
)} H${ageDate.getHours()} M${ageDate.getMinutes()}`,
|
||||||
|
);
|
||||||
if (perResultCallback) await perResultCallback(element);
|
if (perResultCallback) await perResultCallback(element);
|
||||||
}
|
}
|
||||||
const baseStacks =
|
const baseStacks =
|
||||||
|
|
@ -56,13 +59,14 @@ export class AwsCliCommands {
|
||||||
) || [];
|
) || [];
|
||||||
CloudRunnerLogger.log(`Base Stacks ${baseStacks.length}`);
|
CloudRunnerLogger.log(`Base Stacks ${baseStacks.length}`);
|
||||||
for (const element of baseStacks) {
|
for (const element of baseStacks) {
|
||||||
const ageDate = new Date(element.CreationTime.getTime() - Date.now());
|
const ageDate: Date = new Date(Date.now() - element.CreationTime.getTime());
|
||||||
if (verbose)
|
|
||||||
CloudRunnerLogger.log(
|
// if (verbose)
|
||||||
`Base Stack ${
|
CloudRunnerLogger.log(
|
||||||
element.StackName
|
`Task Stack ${element.StackName} - Age D${Math.floor(
|
||||||
} - Age D${ageDate.getHours()} H${ageDate.getHours()} M${ageDate.getMinutes()}`,
|
ageDate.getHours() / 24,
|
||||||
);
|
)} H${ageDate.getHours()} M${ageDate.getMinutes()}`,
|
||||||
|
);
|
||||||
if (perResultCallback) await perResultCallback(element);
|
if (perResultCallback) await perResultCallback(element);
|
||||||
}
|
}
|
||||||
if (stacks === undefined) {
|
if (stacks === undefined) {
|
||||||
|
|
@ -104,7 +108,7 @@ export class AwsCliCommands {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@CliFunction(`aws-list-log-groups`, `List tasks`)
|
@CliFunction(`aws-list-log-groups`, `List tasks`)
|
||||||
static async awsListLogGroups(perResultCallback: any = false, verbose: boolean = false) {
|
static async awsListLogGroups(perResultCallback: any = false) {
|
||||||
process.env.AWS_REGION = Input.region;
|
process.env.AWS_REGION = Input.region;
|
||||||
const ecs = new AWS.CloudWatchLogs();
|
const ecs = new AWS.CloudWatchLogs();
|
||||||
let logStreamInput: AWS.CloudWatchLogs.DescribeLogGroupsRequest = {
|
let logStreamInput: AWS.CloudWatchLogs.DescribeLogGroupsRequest = {
|
||||||
|
|
@ -124,21 +128,20 @@ export class AwsCliCommands {
|
||||||
CloudRunnerLogger.log(`Skipping ${element.logGroupName} no createdAt date`);
|
CloudRunnerLogger.log(`Skipping ${element.logGroupName} no createdAt date`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const ageDate = new Date(new Date(element.creationTime).getTime() - Date.now());
|
const ageDate: Date = new Date(Date.now() - element.creationTime);
|
||||||
if (verbose)
|
|
||||||
CloudRunnerLogger.log(
|
// if (verbose)
|
||||||
`Log Group Name ${
|
CloudRunnerLogger.log(
|
||||||
element.logGroupName
|
`Task Stack ${element.logGroupName} - Age D${Math.floor(
|
||||||
} - Age D${ageDate.getDay()} H${ageDate.getHours()} M${ageDate.getMinutes()} - 1d old ${AwsCliCommands.isOlderThan1day(
|
ageDate.getHours() / 24,
|
||||||
new Date(element.creationTime),
|
)} H${ageDate.getHours()} M${ageDate.getMinutes()}`,
|
||||||
)}`,
|
);
|
||||||
);
|
|
||||||
if (perResultCallback) await perResultCallback(element, element);
|
if (perResultCallback) await perResultCallback(element, element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@CliFunction(`aws-list-jobs`, `List tasks`)
|
@CliFunction(`aws-list-jobs`, `List tasks`)
|
||||||
static async awsListJobs(perResultCallback: any = false, verbose: boolean = false) {
|
static async awsListJobs(perResultCallback: any = false) {
|
||||||
process.env.AWS_REGION = Input.region;
|
process.env.AWS_REGION = Input.region;
|
||||||
const CF = new AWS.CloudFormation();
|
const CF = new AWS.CloudFormation();
|
||||||
const stacks =
|
const stacks =
|
||||||
|
|
@ -148,11 +151,14 @@ export class AwsCliCommands {
|
||||||
) || [];
|
) || [];
|
||||||
CloudRunnerLogger.log(`Stacks ${stacks.length}`);
|
CloudRunnerLogger.log(`Stacks ${stacks.length}`);
|
||||||
for (const element of stacks) {
|
for (const element of stacks) {
|
||||||
const ageDate = new Date(element.CreationTime.getTime() - Date.now());
|
const ageDate: Date = new Date(Date.now() - element.CreationTime.getTime());
|
||||||
if (verbose)
|
|
||||||
CloudRunnerLogger.log(
|
// if (verbose)
|
||||||
`Task Stack ${element.StackName} - Age D${ageDate.getDay()} H${ageDate.getHours()} M${ageDate.getMinutes()}`,
|
CloudRunnerLogger.log(
|
||||||
);
|
`Task Stack ${element.StackName} - Age D${Math.floor(
|
||||||
|
ageDate.getHours() / 24,
|
||||||
|
)} H${ageDate.getHours()} M${ageDate.getMinutes()}`,
|
||||||
|
);
|
||||||
if (perResultCallback) await perResultCallback(element);
|
if (perResultCallback) await perResultCallback(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue