UNPKG

cloud-report

Version:

Collects and analyzes cloud resources

38 lines (37 loc) 1.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const utils_1 = require("../../../utils"); const aws_1 = require("../../../utils/aws"); const base_1 = require("../../base"); class LambdaFunctionsCollector extends base_1.BaseCollector { collect() { return this.getAllFunctions(); } async getAllFunctions() { const self = this; const serviceName = "Lambda"; const lambdaRegions = self.getRegions(serviceName); const functions = {}; for (const region of lambdaRegions) { try { const lambda = self.getClient(serviceName, region); functions[region] = []; let fetchPending = true; let marker; while (fetchPending) { const functionsResponse = await lambda.listFunctions({ Marker: marker }).promise(); functions[region] = functions[region].concat(functionsResponse.Functions); marker = functionsResponse.NextMarker; fetchPending = marker !== undefined && marker !== null; await utils_1.CommonUtil.wait(200); } } catch (error) { aws_1.AWSErrorHandler.handle(error); continue; } } return { functions }; } } exports.LambdaFunctionsCollector = LambdaFunctionsCollector;