UNPKG

@cloud-copilot/iam-collect

Version:

Collect IAM information from AWS Accounts

107 lines 4.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AwsConfigEventBridgeClient = void 0; const client_eventbridge_1 = require("@aws-sdk/client-eventbridge"); const AbstractClient_js_1 = require("../../customClients/AbstractClient.js"); const AwsConfigClientContext_js_1 = require("../AwsConfigClientContext.js"); const awsConfigUtils_js_1 = require("../awsConfigUtils.js"); /** * AWS Config-based EventBridge client implementation * */ class AwsConfigEventBridgeClient extends AbstractClient_js_1.AbstractClient { static clientName = client_eventbridge_1.EventBridgeClient.name; constructor(options, customContext) { super(options, customContext); } /** * Register all EventBridge command implementations */ registerCommands() { this.registerCommand(AwsConfigDescribeEventBusCommand); this.registerCommand(AwsConfigListEventBusesCommand); this.registerCommand(AwsConfigListTagsForResourceCommand); } } exports.AwsConfigEventBridgeClient = AwsConfigEventBridgeClient; /** * Config-based implementation of EventBridge DescribeEventBusCommand * * Maps Events::EventBus Config data to EventBridge DescribeEventBusCommand output format. * Returns event bus policy from configuration.Policy field for IAM analysis. */ const AwsConfigDescribeEventBusCommand = (0, AwsConfigClientContext_js_1.awsConfigCommand)({ command: client_eventbridge_1.DescribeEventBusCommand, execute: async (input, context) => { const eventBusName = input.Name || 'default'; const configuration = context.getCache(eventBusName, 'configuration'); return { Name: configuration.Name || eventBusName, Arn: configuration.Arn, Policy: configuration.Policy, // Note: KmsKeyIdentifier is not available in Config schema KmsKeyIdentifier: undefined }; } }); /** * Config-based implementation of EventBridge ListEventBusesCommand * * Maps Events::EventBus Config data to EventBridge ListEventBusesCommand output format. * Returns event bus listing for IAM analysis and resource discovery. */ const AwsConfigListEventBusesCommand = (0, AwsConfigClientContext_js_1.awsConfigCommand)({ command: client_eventbridge_1.ListEventBusesCommand, execute: async (input, context) => { const query = ` SELECT arn, resourceId, resourceName, configuration.Name, configuration.Arn, configuration.EventSourceName, configuration.Policy, tags WHERE resourceType = 'AWS::Events::EventBus' AND awsRegion = '${context.region}' AND accountId = '${context.accountId}' AND ${awsConfigUtils_js_1.resourceStatusWhereClause} `; const results = await (0, awsConfigUtils_js_1.executeConfigQuery)(query, context); const eventBuses = results.map((result) => { const { configItem, configuration, tags } = (0, awsConfigUtils_js_1.parseConfigItem)(result); // Cache data that will be needed by other commands const eventBusName = configuration.Name || configItem.resourceName; context.putCache(eventBusName, 'configuration', configuration); context.putCache(configItem.arn, 'tags', tags); return { Name: configuration.Name, Arn: configuration.Arn, EventSourceName: configuration.EventSourceName }; }); return { EventBuses: eventBuses }; } }); /** * Config-based implementation of EventBridge ListTagsForResourceCommand * * Maps Events::EventBus Config tag data to EventBridge ListTagsForResourceCommand output format. * Returns event bus tags for resource identification and compliance analysis. */ const AwsConfigListTagsForResourceCommand = (0, AwsConfigClientContext_js_1.awsConfigCommand)({ command: client_eventbridge_1.ListTagsForResourceCommand, execute: async (input, context) => { // Extract event bus name from ARN or use the ARN directly for resourceName lookup const resourceArn = input.ResourceARN; const tags = context.getCache(resourceArn, 'tags'); return { Tags: tags }; } }); //# sourceMappingURL=AwsConfigEventBridgeClient.js.map