UNPKG

@csermet/multiprovider

Version:

cloud-graph provider plugin for AWS used to fetch AWS cloud data.

37 lines (36 loc) 1.42 kB
"use strict"; 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")); /** * EIP */ exports.default = ({ service: eip, data, region, }) => { const connections = []; const { AllocationId: id, NetworkInterfaceId: networkInterfaceId } = eip; /** * Find Network Interfaces * related to this EIP */ const networkInterfaces = data.find(({ name }) => name === services_1.default.networkInterface); if (networkInterfaces?.data?.[region]) { const networkInterfacesInRegion = networkInterfaces.data[region].filter(({ NetworkInterfaceId }) => NetworkInterfaceId === networkInterfaceId); if (!isEmpty_1.default(networkInterfacesInRegion)) { for (const networkInterface of networkInterfacesInRegion) { connections.push({ id: networkInterface.NetworkInterfaceId, resourceType: services_1.default.networkInterface, relation: 'child', field: 'networkInterface', }); } } } const eipResult = { [id]: connections, }; return eipResult; };