cloud-report
Version:
Collects and analyzes cloud resources
40 lines (39 loc) • 1.62 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../../../utils");
const aws_1 = require("../../../utils/aws");
const base_1 = require("../../base");
class DashboardsCollector extends base_1.BaseCollector {
collect(callback) {
return this.getAllDashboards();
}
async getAllDashboards() {
const self = this;
const serviceName = "CloudWatch";
const CloudWatchRegions = self.getRegions(serviceName);
const dashboards = {};
for (const region of CloudWatchRegions) {
try {
const cloudWatchService = self.getClient(serviceName, region);
dashboards[region] = [];
let fetchPending = true;
let marker;
while (fetchPending) {
const dashboardsResponse = await cloudWatchService.listDashboards({ NextToken: marker }).promise();
if (dashboardsResponse.DashboardEntries) {
dashboards[region] = dashboards[region].concat(dashboardsResponse.DashboardEntries);
}
marker = dashboardsResponse.NextToken;
fetchPending = marker !== undefined && marker !== null;
await utils_1.CommonUtil.wait(200);
}
}
catch (error) {
aws_1.AWSErrorHandler.handle(error);
continue;
}
}
return { dashboards };
}
}
exports.DashboardsCollector = DashboardsCollector;