UNPKG

@cloud-copilot/iam-collect

Version:

Collect IAM information from AWS Accounts

39 lines 1.63 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GlueCatalogSync = void 0; const client_glue_1 = require("@aws-sdk/client-glue"); const client_tools_js_1 = require("../../utils/client-tools.js"); const json_js_1 = require("../../utils/json.js"); exports.GlueCatalogSync = { name: 'GlueCatalogSync', awsService: 'glue', execute: async (accountId, region, credentials, storage, endpoint, syncOptions) => { const glueClient = syncOptions.clientPool.client(client_glue_1.GlueClient, credentials, region, endpoint); const policy = await (0, client_tools_js_1.runAndCatchError)('EntityNotFoundException', async () => { const result = await glueClient.send(new client_glue_1.GetResourcePolicyCommand()); return (0, json_js_1.parseIfPresent)(result.PolicyInJson); }); const arn = rootCatalogArn(credentials.partition, accountId, region); if (policy) { await storage.saveResourceMetadata(accountId, arn, 'policy', policy); await storage.saveResourceMetadata(accountId, arn, 'metadata', { arn }); } else { await storage.deleteResource(accountId, arn); } } }; /** * Get the ARN for a root Glue catalog * * @param partition the partition (aws, aws-cn, aws-us-gov) * @param accountId the account id * @param region the region * @returns the ARN for the root Glue catalog */ function rootCatalogArn(partition, accountId, region) { return `arn:${partition}:glue:${region}:${accountId}:catalog`; } //# sourceMappingURL=catalogs.js.map