@csermet/multiprovider
Version:
cloud-graph provider plugin for AWS used to fetch AWS cloud data.
37 lines (36 loc) • 1.3 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
const services_1 = __importDefault(require("../../enums/services"));
/**
* EBS
*/
exports.default = ({ service: volume, data, region, account, }) => {
const connections = [];
const { VolumeId: id, SnapshotId: snapshotId, } = volume;
/**
* Find EBS Snapshot
* related to this EBS Volume
*/
const ebsSnapshots = data.find(({ name }) => name === services_1.default.ebsSnapshot);
if (ebsSnapshots?.data?.[region]) {
const snapshotInRegion = ebsSnapshots.data[region].filter(({ SnapshotId }) => SnapshotId === snapshotId);
if (!isEmpty_1.default(snapshotInRegion)) {
for (const sh of snapshotInRegion) {
connections.push({
id: sh.SnapshotId,
resourceType: services_1.default.ebsSnapshot,
relation: 'child',
field: 'ebsSnapshots',
});
}
}
}
const ebsResult = {
[id]: connections,
};
return ebsResult;
};