@csermet/multiprovider
Version:
cloud-graph provider plugin for AWS used to fetch AWS cloud data.
58 lines (57 loc) • 2.47 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const lodash_1 = require("lodash");
const rds_1 = __importDefault(require("aws-sdk/clients/rds"));
const fetchUtils_1 = require("../../utils/fetchUtils");
const utils_1 = require("../../utils");
const errorLog_1 = __importDefault(require("../../utils/errorLog"));
const format_1 = require("../../utils/format");
const serviceName = 'rdsClusterSnapshot';
const endpoint = utils_1.initTestEndpoint(serviceName);
const errorLog = new errorLog_1.default(serviceName);
/**
* RdsClusterSnapshot
*/
exports.default = async ({ regions, config, }) => {
const result = [];
const activeRegions = regions.split(',');
for (const region of activeRegions) {
const client = new rds_1.default({ ...config, region, endpoint });
let rdsClusterSnapshotData;
try {
rdsClusterSnapshotData = await fetchUtils_1.fetchAllPaginatedData({
getResourcesFn: fetchUtils_1.convertToPromise({
sdkContext: client,
fnName: 'describeDBClusterSnapshots',
}),
accessor: '',
});
}
catch (err) {
errorLog.generateAwsErrorLog({ functionName: 'describeDBClusterSnapshots', err });
}
if (!lodash_1.isEmpty(rdsClusterSnapshotData)) {
for (const snapshot of rdsClusterSnapshotData) {
let snapshotAttributes;
try {
const attributeResponse = await client
.describeDBClusterSnapshotAttributes({
DBClusterSnapshotIdentifier: snapshot.DBClusterSnapshotIdentifier,
})
.promise();
snapshotAttributes =
attributeResponse?.DBClusterSnapshotAttributesResult?.DBClusterSnapshotAttributes;
}
catch (err) {
errorLog.generateAwsErrorLog({ functionName: 'describeDBClusterSnapshotAttributes', err });
}
result.push({ ...snapshot, Tags: format_1.convertAwsTagsToTagMap(snapshot?.TagList), attributes: snapshotAttributes, region });
}
}
}
errorLog.reset();
return lodash_1.groupBy(result, 'region');
};