@csermet/multiprovider
Version:
cloud-graph provider plugin for AWS used to fetch AWS cloud data.
38 lines (37 loc) • 1.44 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"));
/**
* Vpc Peering Connection
*/
exports.default = ({ service: vpcPeeringConnection, data, region, }) => {
const connections = [];
const { VpcPeeringConnectionId: id, AccepterVpcInfo: accepterVpcInfo, RequesterVpcInfo: requesterVpcInfo, } = vpcPeeringConnection;
/**
* Find VPCs
* related to this Vpc Peering Connection
*/
const vpcs = data.find(({ name }) => name === services_1.default.vpc);
if (vpcs?.data?.[region]) {
const dataAtRegion = vpcs.data[region].filter(({ VpcId }) => VpcId === accepterVpcInfo?.VpcId || VpcId === requesterVpcInfo?.VpcId);
if (!isEmpty_1.default(dataAtRegion)) {
for (const vpc of dataAtRegion) {
const { VpcId } = vpc;
connections.push({
id: VpcId,
resourceType: services_1.default.vpc,
relation: 'child',
field: 'vpc',
});
}
}
}
const vpcPeeringConnectionResult = {
[id]: connections,
};
return vpcPeeringConnectionResult;
};