UNPKG

@cloud-copilot/iam-collect

Version:

Collect IAM information from AWS Accounts

102 lines 3.79 kB
import { GetQueueAttributesCommand, ListQueuesCommand, ListQueueTagsCommand, SQSClient } from '@aws-sdk/client-sqs'; import {} from '../../aws/coreAuth.js'; import { AbstractClient } from '../../customClients/AbstractClient.js'; import { awsConfigCommand } from '../AwsConfigClientContext.js'; import { executeConfigQuery, parseConfigItem, resourceStatusWhereClause } from '../awsConfigUtils.js'; /** * AWS Config-based SQS client implementation */ export class AwsConfigSQSClient extends AbstractClient { constructor(options, customContext) { super(options, customContext); } /** * Register all SQS command implementations */ registerCommands() { this.registerCommand(AwsConfigGetQueueAttributesCommand); this.registerCommand(AwsConfigListQueueTagsCommand); this.registerCommand(AwsConfigListQueuesCommand); } } AwsConfigSQSClient.clientName = SQSClient.name; /** * Config-based implementation of SQS ListQueuesCommand * * Maps SQS::Queue Config data to SQS ListQueuesCommand output format. * Returns queue URL listing for IAM analysis and resource discovery. */ const AwsConfigListQueuesCommand = awsConfigCommand({ command: ListQueuesCommand, execute: async (input, context) => { const query = ` SELECT arn, resourceId, resourceName, configuration.QueueUrl, configuration.QueueName, configuration.KmsMasterKeyId, configuration.Policy, tags WHERE resourceType = 'AWS::SQS::Queue' AND awsRegion = '${context.region}' AND accountId = '${context.accountId}' AND ${resourceStatusWhereClause} `; const results = await executeConfigQuery(query, context); const queueUrls = results.map((result) => { const { configItem, configuration, tags } = parseConfigItem(result); context.putCache(configItem.resourceId, 'configuration', configuration); context.putCache(configItem.resourceId, 'tags', tags); // Use QueueUrl from config if available, otherwise construct from QueueName return configItem.resourceId; }); return { QueueUrls: queueUrls, NextToken: undefined // Config doesn't provide pagination markers }; } }); /** * Config-based implementation of SQS GetQueueAttributesCommand * * Maps SQS::Queue Config data to SQS GetQueueAttributesCommand output format. * Returns only the attributes used by the sync: KmsMasterKeyId, Policy. */ const AwsConfigGetQueueAttributesCommand = awsConfigCommand({ command: GetQueueAttributesCommand, execute: async (input, context) => { const queueUrl = input.QueueUrl; const configuration = context.getCache(queueUrl, 'configuration'); // Return only the attributes used by the sync operations const attributes = {}; if (configuration.KmsMasterKeyId) { attributes['KmsMasterKeyId'] = configuration.KmsMasterKeyId; } if (configuration.Policy) { attributes['Policy'] = configuration.Policy; } return { Attributes: attributes }; } }); /** * Config-based implementation of SQS ListQueueTagsCommand * * Maps SQS::Queue Config tag data to SQS ListQueueTagsCommand output format. * Returns queue tags for resource identification and compliance analysis. */ const AwsConfigListQueueTagsCommand = awsConfigCommand({ command: ListQueueTagsCommand, execute: async (input, context) => { const queueUrl = input.QueueUrl; const value = context.getCache(queueUrl, 'tags'); return { Tags: value || {} }; } }); //# sourceMappingURL=AwsConfigSQSClient.js.map