cloud-report
Version:
Collects and analyzes cloud resources
43 lines (42 loc) • 1.82 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const _1 = require(".");
const utils_1 = require("../../../utils");
const aws_1 = require("../../../utils/aws");
const base_1 = require("../../base");
class RedshiftAuditLogsCollector extends base_1.BaseCollector {
collect(callback) {
return this.getAuditLogs();
}
async getAuditLogs() {
const self = this;
const serviceName = "Redshift";
const redshiftRegions = self.getRegions(serviceName);
const redshiftClustersCollector = new _1.RedshiftClustersCollector();
redshiftClustersCollector.setSession(self.getSession());
const audit_logs = {};
try {
const clustersData = await utils_1.CollectorUtil.cachedCollect(redshiftClustersCollector);
for (const region of redshiftRegions) {
try {
const redshift = self.getClient(serviceName, region);
audit_logs[region] = {};
const regionClusters = clustersData.clusters[region];
for (const cluster of regionClusters) {
const loggingStatus = await redshift.describeLoggingStatus({ ClusterIdentifier: cluster.ClusterIdentifier }).promise();
audit_logs[region][cluster.ClusterIdentifier] = loggingStatus;
await utils_1.CommonUtil.wait(200);
}
}
catch (error) {
aws_1.AWSErrorHandler.handle(error);
}
}
}
catch (error) {
aws_1.AWSErrorHandler.handle(error);
}
return { audit_logs };
}
}
exports.RedshiftAuditLogsCollector = RedshiftAuditLogsCollector;