UNPKG

@cloud-copilot/iam-collect

Version:

Collect IAM information from AWS Accounts

42 lines 1.63 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.index = index; const config_js_1 = require("../config/config.js"); const indexMap_js_1 = require("../indexing/indexMap.js"); const runIndexers_js_1 = require("../indexing/runIndexers.js"); const util_js_1 = require("../jobs/util.js"); const util_js_2 = require("../persistence/util.js"); const services_js_1 = require("../services.js"); async function index(configs, partition, accountIds, regions, services, concurrency) { const storageConfig = (0, config_js_1.getStorageConfig)(configs); if (!storageConfig) { throw new Error('No storage configuration found. Cannot index data.'); } const storage = (0, util_js_2.createStorageClient)(storageConfig, partition); if (accountIds.length === 0) { accountIds = await storage.listAccountIds(); } if (services.length === 0) { services = services_js_1.allServices; } if (!concurrency || concurrency <= 0) { concurrency = (0, util_js_1.defaultConcurrency)(); } const indexers = services.reduce((allIndexers, service) => { allIndexers.push(...(0, indexMap_js_1.getIndexersForService)(service)); return allIndexers; }, []); const jobs = []; for (const accountId of accountIds) { for (const indexer of indexers) { jobs.push({ indexer, accountId, regions: regions, partition }); } } await (0, runIndexers_js_1.runIndexJobs)(jobs, storageConfig, concurrency); } //# sourceMappingURL=index.js.map