UNPKG

@cloud-copilot/iam-collect

Version:

Collect IAM information from AWS Accounts

30 lines 1.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.syncData = syncData; /** * Synchronize the data for a given set of resources. * This will: * 1. Delete any resources that meet the `resourceTypeParts` and are not in the `records` list. * 2. Save all resources that are in the `records`. * * @param records the records to synchronize, must include the ARN * @param storage the storage client to use for updating metadata * @param accountId the account ID to synchronize data for * @param resourceTypeParts the resource type parts to synchronize * @param writeOnly if true, will only write data and not delete any existing data */ async function syncData(records, storage, accountId, resourceTypeParts, writeOnly) { if (!writeOnly) { const allArns = records.map((r) => r.arn); await storage.syncResourceList(accountId, resourceTypeParts, allArns); } for (const record of records) { for (const [key, value] of Object.entries(record)) { if (key === 'arn') { continue; } await storage.saveResourceMetadata(accountId, record.arn, key, value); } } } //# sourceMappingURL=sync.js.map