UNPKG

@csermet/multiprovider

Version:

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

64 lines (63 loc) 2.34 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const sdk_1 = require("@cloudgraph/sdk"); const isEmpty_1 = __importDefault(require("lodash/isEmpty")); const format_1 = require("../../utils/format"); /** * Elastic Beanstalk */ exports.default = ({ account, region, service: env, }) => { const { ApplicationName: applicationName, CNAME: cname, Description: description, EndpointURL: endpointUrl, EnvironmentArn: arn, EnvironmentId: id, EnvironmentName: name, PlatformArn: platformArn, SolutionStackName: solutionStackName, Tier: { Name: tier } = {}, VersionLabel: versionLabel, resources = [], settings = [], Tags = {}, } = env; let optionSettings = []; if (!isEmpty_1.default(settings)) { optionSettings = settings .flatMap(({ OptionSettings }) => OptionSettings) .map(({ Namespace: namespace, OptionName: optionName, Value: value }) => ({ id: sdk_1.generateUniqueId({ arn, namespace, optionName, value, }), optionName, value, namespace, })); } let envResources = []; if (!isEmpty_1.default(resources)) { envResources = Object.entries(resources).map(([key, item]) => ({ id: sdk_1.generateUniqueId({ arn, key, item, }), name: key, /* We ask for the type because resources(EnvironmentResourceDescription) is an object with whose property types can be string, array of strings or array of objects that can contain a single property named Name or Id */ value: typeof item === 'string' ? [item] : item.map(i => i.Name || i.Id || i), })); } return { accountId: account, id, name, arn, tier, description, versionLabel, solutionStackName, cname, applicationName, endpointUrl, platformArn, resources: envResources, settings: optionSettings, region, tags: format_1.formatTagsFromMap(Tags), }; };