@jaypie/mcp 0.7.9 → 0.7.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -138,10 +138,20 @@ export interface AwsProfile {
138
138
  region?: string;
139
139
  sso_start_url?: string;
140
140
  }
141
+ export interface AwsValidationResult {
142
+ success: boolean;
143
+ cliAvailable: boolean;
144
+ cliVersion?: string;
145
+ profiles: AwsProfile[];
146
+ }
141
147
  /**
142
148
  * Execute an AWS CLI command and return parsed JSON output
143
149
  */
144
150
  export declare function executeAwsCommand<T>(service: string, command: string, args: string[], options?: AwsCommandOptions, logger?: Logger): Promise<AwsCommandResult<T>>;
151
+ /**
152
+ * Validate AWS setup without making API calls
153
+ */
154
+ export declare function validateAwsSetup(): Promise<AwsValidationResult>;
145
155
  /**
146
156
  * List available AWS profiles from ~/.aws/config and ~/.aws/credentials
147
157
  */
@@ -133,6 +133,47 @@ async function executeAwsCommand(service, command, args, options = {}, logger =
133
133
  });
134
134
  });
135
135
  }
136
+ /**
137
+ * Check if AWS CLI is available and get its version
138
+ */
139
+ async function checkAwsCliVersion() {
140
+ return new Promise((resolve) => {
141
+ const proc = spawn("aws", ["--version"]);
142
+ let stdout = "";
143
+ proc.stdout.on("data", (data) => {
144
+ stdout += data.toString();
145
+ });
146
+ proc.on("close", (code) => {
147
+ if (code === 0) {
148
+ // Output is like "aws-cli/2.15.0 Python/3.11.6 Darwin/23.2.0 source/arm64"
149
+ const match = stdout.match(/aws-cli\/([\d.]+)/);
150
+ resolve({
151
+ available: true,
152
+ version: match ? match[1] : stdout.trim(),
153
+ });
154
+ }
155
+ else {
156
+ resolve({ available: false });
157
+ }
158
+ });
159
+ proc.on("error", () => {
160
+ resolve({ available: false });
161
+ });
162
+ });
163
+ }
164
+ /**
165
+ * Validate AWS setup without making API calls
166
+ */
167
+ async function validateAwsSetup() {
168
+ const cliCheck = await checkAwsCliVersion();
169
+ const profilesResult = await listAwsProfiles();
170
+ return {
171
+ cliAvailable: cliCheck.available,
172
+ cliVersion: cliCheck.version,
173
+ profiles: profilesResult.success ? (profilesResult.data ?? []) : [],
174
+ success: cliCheck.available,
175
+ };
176
+ }
136
177
  /**
137
178
  * List available AWS profiles from ~/.aws/config and ~/.aws/credentials
138
179
  */
@@ -324,5 +365,5 @@ async function purgeSQSQueue(options, logger = nullLogger) {
324
365
  return executeAwsCommand("sqs", "purge-queue", ["--queue-url", options.queueUrl], { profile: options.profile, region: options.region }, logger);
325
366
  }
326
367
 
327
- export { describeDynamoDBTable, describeStack, executeAwsCommand, filterLogEvents, getDynamoDBItem, getLambdaFunction, getSQSQueueAttributes, listAwsProfiles, listLambdaFunctions, listS3Objects, listSQSQueues, listStepFunctionExecutions, purgeSQSQueue, queryDynamoDB, receiveSQSMessage, scanDynamoDB, stopStepFunctionExecution };
368
+ export { describeDynamoDBTable, describeStack, executeAwsCommand, filterLogEvents, getDynamoDBItem, getLambdaFunction, getSQSQueueAttributes, listAwsProfiles, listLambdaFunctions, listS3Objects, listSQSQueues, listStepFunctionExecutions, purgeSQSQueue, queryDynamoDB, receiveSQSMessage, scanDynamoDB, stopStepFunctionExecution, validateAwsSetup };
328
369
  //# sourceMappingURL=aws.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"aws.js","sources":["../../../src/suites/aws/aws.ts"],"sourcesContent":["/**\n * AWS CLI integration module\n * Provides a structured interface for common AWS operations via the AWS CLI\n */\nimport { spawn } from \"node:child_process\";\nimport * as fs from \"node:fs/promises\";\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\n\n// Logger interface matching the pattern from datadog.ts\ninterface Logger {\n info: (message: string, ...args: unknown[]) => void;\n error: (message: string, ...args: unknown[]) => void;\n}\n\nconst nullLogger: Logger = {\n info: () => {},\n error: () => {},\n};\n\n// Common AWS command options\nexport interface AwsCommandOptions {\n profile?: string;\n region?: string;\n}\n\n// Generic result type for AWS commands\nexport interface AwsCommandResult<T> {\n success: boolean;\n data?: T;\n error?: string;\n}\n\n// Step Functions types\nexport interface StepFunctionExecution {\n executionArn: string;\n stateMachineArn: string;\n name: string;\n status: string;\n startDate: string;\n stopDate?: string;\n}\n\nexport interface StepFunctionsListExecutionsOptions extends AwsCommandOptions {\n stateMachineArn: string;\n statusFilter?:\n | \"RUNNING\"\n | \"SUCCEEDED\"\n | \"FAILED\"\n | \"TIMED_OUT\"\n | \"ABORTED\"\n | \"PENDING_REDRIVE\";\n maxResults?: number;\n}\n\nexport interface StepFunctionsStopExecutionOptions extends AwsCommandOptions {\n executionArn: string;\n cause?: string;\n}\n\n// Lambda types\nexport interface LambdaFunction {\n FunctionName: string;\n FunctionArn: string;\n Runtime?: string;\n Handler?: string;\n CodeSize: number;\n Description?: string;\n Timeout?: number;\n MemorySize?: number;\n LastModified: string;\n Version?: string;\n}\n\nexport interface LambdaListFunctionsOptions extends AwsCommandOptions {\n functionNamePrefix?: string;\n maxResults?: number;\n}\n\nexport interface LambdaGetFunctionOptions extends AwsCommandOptions {\n functionName: string;\n}\n\n// CloudWatch Logs types\nexport interface LogEvent {\n timestamp: number;\n message: string;\n ingestionTime?: number;\n logStreamName?: string;\n}\n\nexport interface CloudWatchLogsFilterOptions extends AwsCommandOptions {\n logGroupName: string;\n filterPattern?: string;\n startTime?: string;\n endTime?: string;\n limit?: number;\n}\n\n// S3 types\nexport interface S3Object {\n Key: string;\n LastModified: string;\n ETag: string;\n Size: number;\n StorageClass: string;\n}\n\nexport interface S3ListObjectsOptions extends AwsCommandOptions {\n bucket: string;\n prefix?: string;\n maxResults?: number;\n}\n\n// CloudFormation types\nexport interface CloudFormationStack {\n StackName: string;\n StackId: string;\n StackStatus: string;\n StackStatusReason?: string;\n CreationTime: string;\n LastUpdatedTime?: string;\n Description?: string;\n Outputs?: Array<{\n OutputKey: string;\n OutputValue: string;\n Description?: string;\n }>;\n Parameters?: Array<{\n ParameterKey: string;\n ParameterValue: string;\n }>;\n}\n\nexport interface CloudFormationDescribeStackOptions extends AwsCommandOptions {\n stackName: string;\n}\n\n// DynamoDB types\nexport interface DynamoDBDescribeTableOptions extends AwsCommandOptions {\n tableName: string;\n}\n\nexport interface DynamoDBScanOptions extends AwsCommandOptions {\n tableName: string;\n filterExpression?: string;\n expressionAttributeValues?: string;\n limit?: number;\n}\n\nexport interface DynamoDBQueryOptions extends AwsCommandOptions {\n tableName: string;\n keyConditionExpression: string;\n expressionAttributeValues: string;\n indexName?: string;\n filterExpression?: string;\n limit?: number;\n scanIndexForward?: boolean;\n}\n\nexport interface DynamoDBGetItemOptions extends AwsCommandOptions {\n tableName: string;\n key: string;\n}\n\n// SQS types\nexport interface SQSQueue {\n QueueUrl: string;\n}\n\nexport interface SQSListQueuesOptions extends AwsCommandOptions {\n queueNamePrefix?: string;\n}\n\nexport interface SQSGetQueueAttributesOptions extends AwsCommandOptions {\n queueUrl: string;\n}\n\nexport interface SQSReceiveMessageOptions extends AwsCommandOptions {\n queueUrl: string;\n maxNumberOfMessages?: number;\n visibilityTimeout?: number;\n}\n\nexport interface SQSPurgeQueueOptions extends AwsCommandOptions {\n queueUrl: string;\n}\n\n// AWS Profile\nexport interface AwsProfile {\n name: string;\n source: \"config\" | \"credentials\";\n region?: string;\n sso_start_url?: string;\n}\n\n/**\n * Parse AWS CLI error messages into user-friendly descriptions\n */\nfunction parseAwsError(\n stderr: string,\n service: string,\n command: string,\n): string {\n if (stderr.includes(\"ExpiredToken\") || stderr.includes(\"Token has expired\")) {\n return \"AWS credentials have expired. Run 'aws sso login' or refresh your credentials.\";\n }\n if (\n stderr.includes(\"NoCredentialProviders\") ||\n stderr.includes(\"Unable to locate credentials\")\n ) {\n return \"No AWS credentials found. Configure credentials with 'aws configure' or 'aws sso login'.\";\n }\n if (stderr.includes(\"AccessDenied\") || stderr.includes(\"Access Denied\")) {\n return `Access denied for ${service}:${command}. Check your IAM permissions.`;\n }\n if (stderr.includes(\"ResourceNotFoundException\")) {\n return `Resource not found. Check that the specified resource exists in the correct region.`;\n }\n if (stderr.includes(\"ValidationException\")) {\n const match = stderr.match(/ValidationException[^:]*:\\s*(.+)/);\n return match\n ? `Validation error: ${match[1].trim()}`\n : \"Validation error in request parameters.\";\n }\n if (\n stderr.includes(\"ThrottlingException\") ||\n stderr.includes(\"Rate exceeded\")\n ) {\n return \"AWS API rate limit exceeded. Wait a moment and try again.\";\n }\n if (stderr.includes(\"InvalidParameterValue\")) {\n const match = stderr.match(/InvalidParameterValue[^:]*:\\s*(.+)/);\n return match\n ? `Invalid parameter: ${match[1].trim()}`\n : \"Invalid parameter value provided.\";\n }\n return stderr.trim();\n}\n\n/**\n * Parse relative time strings like 'now-1h' to Unix timestamps\n */\nfunction parseRelativeTime(timeStr: string): number {\n const now = Date.now();\n\n if (timeStr === \"now\") {\n return now;\n }\n\n // Handle relative time like 'now-15m', 'now-1h', 'now-1d'\n const relativeMatch = timeStr.match(/^now-(\\d+)([smhd])$/);\n if (relativeMatch) {\n const value = parseInt(relativeMatch[1], 10);\n const unit = relativeMatch[2];\n const multipliers: Record<string, number> = {\n s: 1000,\n m: 60 * 1000,\n h: 60 * 60 * 1000,\n d: 24 * 60 * 60 * 1000,\n };\n return now - value * multipliers[unit];\n }\n\n // Handle ISO 8601 format\n const parsed = Date.parse(timeStr);\n if (!isNaN(parsed)) {\n return parsed;\n }\n\n // Default to the current time if parsing fails\n return now;\n}\n\n/**\n * Execute an AWS CLI command and return parsed JSON output\n */\nexport async function executeAwsCommand<T>(\n service: string,\n command: string,\n args: string[],\n options: AwsCommandOptions = {},\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<T>> {\n const fullArgs = [service, command, ...args, \"--output\", \"json\"];\n\n if (options.profile) {\n fullArgs.push(\"--profile\", options.profile);\n }\n if (options.region) {\n fullArgs.push(\"--region\", options.region);\n }\n\n logger.info(`Executing: aws ${fullArgs.join(\" \")}`);\n\n return new Promise((resolve) => {\n const proc = spawn(\"aws\", fullArgs);\n let stdout = \"\";\n let stderr = \"\";\n\n proc.stdout.on(\"data\", (data) => {\n stdout += data.toString();\n });\n proc.stderr.on(\"data\", (data) => {\n stderr += data.toString();\n });\n\n proc.on(\"close\", (code) => {\n if (code !== 0) {\n logger.error(`AWS CLI error: ${stderr}`);\n resolve({\n success: false,\n error: parseAwsError(stderr, service, command),\n });\n return;\n }\n\n // Handle empty output (some commands return nothing on success)\n if (!stdout.trim()) {\n resolve({ success: true });\n return;\n }\n\n try {\n const data = JSON.parse(stdout) as T;\n resolve({ success: true, data });\n } catch {\n // Some commands return plain text\n resolve({ success: true, data: stdout.trim() as unknown as T });\n }\n });\n\n proc.on(\"error\", (error) => {\n if (error.message.includes(\"ENOENT\")) {\n resolve({\n success: false,\n error:\n \"AWS CLI not found. Install it from https://aws.amazon.com/cli/\",\n });\n } else {\n resolve({ success: false, error: error.message });\n }\n });\n });\n}\n\n/**\n * List available AWS profiles from ~/.aws/config and ~/.aws/credentials\n */\nexport async function listAwsProfiles(\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<AwsProfile[]>> {\n const profiles: AwsProfile[] = [];\n const homeDir = os.homedir();\n\n try {\n // Parse ~/.aws/config\n const configPath = path.join(homeDir, \".aws\", \"config\");\n try {\n const configContent = await fs.readFile(configPath, \"utf-8\");\n const profileRegex = /\\[profile\\s+([^\\]]+)\\]|\\[default\\]/g;\n let match;\n while ((match = profileRegex.exec(configContent)) !== null) {\n const name = match[1] || \"default\";\n profiles.push({\n name,\n source: \"config\",\n });\n }\n logger.info(`Found ${profiles.length} profiles in config`);\n } catch {\n logger.info(\"No ~/.aws/config file found\");\n }\n\n // Parse ~/.aws/credentials\n const credentialsPath = path.join(homeDir, \".aws\", \"credentials\");\n try {\n const credentialsContent = await fs.readFile(credentialsPath, \"utf-8\");\n const profileRegex = /\\[([^\\]]+)\\]/g;\n let match;\n while ((match = profileRegex.exec(credentialsContent)) !== null) {\n const name = match[1];\n // Only add if not already in the list\n if (!profiles.find((p) => p.name === name)) {\n profiles.push({\n name,\n source: \"credentials\",\n });\n }\n }\n logger.info(`Total profiles after credentials: ${profiles.length}`);\n } catch {\n logger.info(\"No ~/.aws/credentials file found\");\n }\n\n return { success: true, data: profiles };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown error\";\n logger.error(`Error listing profiles: ${errorMessage}`);\n return { success: false, error: errorMessage };\n }\n}\n\n// Step Functions operations\nexport async function listStepFunctionExecutions(\n options: StepFunctionsListExecutionsOptions,\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<{ executions: StepFunctionExecution[] }>> {\n const args = [\"--state-machine-arn\", options.stateMachineArn];\n if (options.statusFilter) {\n args.push(\"--status-filter\", options.statusFilter);\n }\n if (options.maxResults) {\n args.push(\"--max-results\", String(options.maxResults));\n }\n\n return executeAwsCommand(\n \"stepfunctions\",\n \"list-executions\",\n args,\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n\nexport async function stopStepFunctionExecution(\n options: StepFunctionsStopExecutionOptions,\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<{ stopDate: string }>> {\n const args = [\"--execution-arn\", options.executionArn];\n if (options.cause) {\n args.push(\"--cause\", options.cause);\n }\n\n return executeAwsCommand(\n \"stepfunctions\",\n \"stop-execution\",\n args,\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n\n// Lambda operations\nexport async function listLambdaFunctions(\n options: LambdaListFunctionsOptions = {},\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<{ Functions: LambdaFunction[] }>> {\n const args: string[] = [];\n if (options.maxResults) {\n args.push(\"--max-items\", String(options.maxResults));\n }\n\n const result = await executeAwsCommand<{ Functions: LambdaFunction[] }>(\n \"lambda\",\n \"list-functions\",\n args,\n { profile: options.profile, region: options.region },\n logger,\n );\n\n // Filter by prefix if specified\n if (result.success && result.data && options.functionNamePrefix) {\n result.data.Functions = result.data.Functions.filter((f) =>\n f.FunctionName.startsWith(options.functionNamePrefix!),\n );\n }\n\n return result;\n}\n\nexport async function getLambdaFunction(\n options: LambdaGetFunctionOptions,\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<{ Configuration: LambdaFunction }>> {\n return executeAwsCommand(\n \"lambda\",\n \"get-function\",\n [\"--function-name\", options.functionName],\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n\n// CloudWatch Logs operations\nexport async function filterLogEvents(\n options: CloudWatchLogsFilterOptions,\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<{ events: LogEvent[] }>> {\n const args = [\"--log-group-name\", options.logGroupName];\n\n if (options.filterPattern) {\n args.push(\"--filter-pattern\", options.filterPattern);\n }\n if (options.startTime) {\n const startMs = parseRelativeTime(options.startTime);\n args.push(\"--start-time\", String(startMs));\n }\n if (options.endTime) {\n const endMs = parseRelativeTime(options.endTime);\n args.push(\"--end-time\", String(endMs));\n }\n if (options.limit) {\n args.push(\"--limit\", String(options.limit));\n }\n\n return executeAwsCommand(\n \"logs\",\n \"filter-log-events\",\n args,\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n\n// S3 operations\nexport async function listS3Objects(\n options: S3ListObjectsOptions,\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<{ Contents: S3Object[] }>> {\n const args = [\"--bucket\", options.bucket];\n if (options.prefix) {\n args.push(\"--prefix\", options.prefix);\n }\n if (options.maxResults) {\n args.push(\"--max-items\", String(options.maxResults));\n }\n\n return executeAwsCommand(\n \"s3api\",\n \"list-objects-v2\",\n args,\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n\n// CloudFormation operations\nexport async function describeStack(\n options: CloudFormationDescribeStackOptions,\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<{ Stacks: CloudFormationStack[] }>> {\n return executeAwsCommand(\n \"cloudformation\",\n \"describe-stacks\",\n [\"--stack-name\", options.stackName],\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n\n// DynamoDB operations\nexport async function describeDynamoDBTable(\n options: DynamoDBDescribeTableOptions,\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<{ Table: Record<string, unknown> }>> {\n return executeAwsCommand(\n \"dynamodb\",\n \"describe-table\",\n [\"--table-name\", options.tableName],\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n\nexport async function scanDynamoDB(\n options: DynamoDBScanOptions,\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<{ Items: Record<string, unknown>[] }>> {\n const args = [\"--table-name\", options.tableName];\n if (options.filterExpression) {\n args.push(\"--filter-expression\", options.filterExpression);\n }\n if (options.expressionAttributeValues) {\n args.push(\n \"--expression-attribute-values\",\n options.expressionAttributeValues,\n );\n }\n if (options.limit) {\n args.push(\"--limit\", String(options.limit));\n }\n\n return executeAwsCommand(\n \"dynamodb\",\n \"scan\",\n args,\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n\nexport async function queryDynamoDB(\n options: DynamoDBQueryOptions,\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<{ Items: Record<string, unknown>[] }>> {\n const args = [\n \"--table-name\",\n options.tableName,\n \"--key-condition-expression\",\n options.keyConditionExpression,\n \"--expression-attribute-values\",\n options.expressionAttributeValues,\n ];\n if (options.indexName) {\n args.push(\"--index-name\", options.indexName);\n }\n if (options.filterExpression) {\n args.push(\"--filter-expression\", options.filterExpression);\n }\n if (options.limit) {\n args.push(\"--limit\", String(options.limit));\n }\n if (options.scanIndexForward === false) {\n args.push(\"--no-scan-index-forward\");\n }\n\n return executeAwsCommand(\n \"dynamodb\",\n \"query\",\n args,\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n\nexport async function getDynamoDBItem(\n options: DynamoDBGetItemOptions,\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<{ Item: Record<string, unknown> }>> {\n return executeAwsCommand(\n \"dynamodb\",\n \"get-item\",\n [\"--table-name\", options.tableName, \"--key\", options.key],\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n\n// SQS operations\nexport async function listSQSQueues(\n options: SQSListQueuesOptions = {},\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<{ QueueUrls: string[] }>> {\n const args: string[] = [];\n if (options.queueNamePrefix) {\n args.push(\"--queue-name-prefix\", options.queueNamePrefix);\n }\n\n return executeAwsCommand(\n \"sqs\",\n \"list-queues\",\n args,\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n\nexport async function getSQSQueueAttributes(\n options: SQSGetQueueAttributesOptions,\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<{ Attributes: Record<string, string> }>> {\n return executeAwsCommand(\n \"sqs\",\n \"get-queue-attributes\",\n [\"--queue-url\", options.queueUrl, \"--attribute-names\", \"All\"],\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n\nexport async function receiveSQSMessage(\n options: SQSReceiveMessageOptions,\n logger: Logger = nullLogger,\n): Promise<\n AwsCommandResult<{\n Messages: Array<{\n MessageId: string;\n ReceiptHandle: string;\n Body: string;\n Attributes?: Record<string, string>;\n }>;\n }>\n> {\n const args = [\"--queue-url\", options.queueUrl];\n if (options.maxNumberOfMessages) {\n args.push(\"--max-number-of-messages\", String(options.maxNumberOfMessages));\n }\n if (options.visibilityTimeout) {\n args.push(\"--visibility-timeout\", String(options.visibilityTimeout));\n }\n args.push(\"--attribute-names\", \"All\");\n\n return executeAwsCommand(\n \"sqs\",\n \"receive-message\",\n args,\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n\nexport async function purgeSQSQueue(\n options: SQSPurgeQueueOptions,\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<void>> {\n return executeAwsCommand(\n \"sqs\",\n \"purge-queue\",\n [\"--queue-url\", options.queueUrl],\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n"],"names":[],"mappings":";;;;;AAAA;;;AAGG;AAYH,MAAM,UAAU,GAAW;AACzB,IAAA,IAAI,EAAE,MAAK,EAAE,CAAC;AACd,IAAA,KAAK,EAAE,MAAK,EAAE,CAAC;CAChB;AAkLD;;AAEG;AACH,SAAS,aAAa,CACpB,MAAc,EACd,OAAe,EACf,OAAe,EAAA;AAEf,IAAA,IAAI,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,MAAM,CAAC,QAAQ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ACP;AACH;;;;"}
1
+ {"version":3,"file":"aws.js","sources":["../../../src/suites/aws/aws.ts"],"sourcesContent":["/**\n * AWS CLI integration module\n * Provides a structured interface for common AWS operations via the AWS CLI\n */\nimport { spawn } from \"node:child_process\";\nimport * as fs from \"node:fs/promises\";\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\n\n// Logger interface matching the pattern from datadog.ts\ninterface Logger {\n info: (message: string, ...args: unknown[]) => void;\n error: (message: string, ...args: unknown[]) => void;\n}\n\nconst nullLogger: Logger = {\n info: () => {},\n error: () => {},\n};\n\n// Common AWS command options\nexport interface AwsCommandOptions {\n profile?: string;\n region?: string;\n}\n\n// Generic result type for AWS commands\nexport interface AwsCommandResult<T> {\n success: boolean;\n data?: T;\n error?: string;\n}\n\n// Step Functions types\nexport interface StepFunctionExecution {\n executionArn: string;\n stateMachineArn: string;\n name: string;\n status: string;\n startDate: string;\n stopDate?: string;\n}\n\nexport interface StepFunctionsListExecutionsOptions extends AwsCommandOptions {\n stateMachineArn: string;\n statusFilter?:\n | \"RUNNING\"\n | \"SUCCEEDED\"\n | \"FAILED\"\n | \"TIMED_OUT\"\n | \"ABORTED\"\n | \"PENDING_REDRIVE\";\n maxResults?: number;\n}\n\nexport interface StepFunctionsStopExecutionOptions extends AwsCommandOptions {\n executionArn: string;\n cause?: string;\n}\n\n// Lambda types\nexport interface LambdaFunction {\n FunctionName: string;\n FunctionArn: string;\n Runtime?: string;\n Handler?: string;\n CodeSize: number;\n Description?: string;\n Timeout?: number;\n MemorySize?: number;\n LastModified: string;\n Version?: string;\n}\n\nexport interface LambdaListFunctionsOptions extends AwsCommandOptions {\n functionNamePrefix?: string;\n maxResults?: number;\n}\n\nexport interface LambdaGetFunctionOptions extends AwsCommandOptions {\n functionName: string;\n}\n\n// CloudWatch Logs types\nexport interface LogEvent {\n timestamp: number;\n message: string;\n ingestionTime?: number;\n logStreamName?: string;\n}\n\nexport interface CloudWatchLogsFilterOptions extends AwsCommandOptions {\n logGroupName: string;\n filterPattern?: string;\n startTime?: string;\n endTime?: string;\n limit?: number;\n}\n\n// S3 types\nexport interface S3Object {\n Key: string;\n LastModified: string;\n ETag: string;\n Size: number;\n StorageClass: string;\n}\n\nexport interface S3ListObjectsOptions extends AwsCommandOptions {\n bucket: string;\n prefix?: string;\n maxResults?: number;\n}\n\n// CloudFormation types\nexport interface CloudFormationStack {\n StackName: string;\n StackId: string;\n StackStatus: string;\n StackStatusReason?: string;\n CreationTime: string;\n LastUpdatedTime?: string;\n Description?: string;\n Outputs?: Array<{\n OutputKey: string;\n OutputValue: string;\n Description?: string;\n }>;\n Parameters?: Array<{\n ParameterKey: string;\n ParameterValue: string;\n }>;\n}\n\nexport interface CloudFormationDescribeStackOptions extends AwsCommandOptions {\n stackName: string;\n}\n\n// DynamoDB types\nexport interface DynamoDBDescribeTableOptions extends AwsCommandOptions {\n tableName: string;\n}\n\nexport interface DynamoDBScanOptions extends AwsCommandOptions {\n tableName: string;\n filterExpression?: string;\n expressionAttributeValues?: string;\n limit?: number;\n}\n\nexport interface DynamoDBQueryOptions extends AwsCommandOptions {\n tableName: string;\n keyConditionExpression: string;\n expressionAttributeValues: string;\n indexName?: string;\n filterExpression?: string;\n limit?: number;\n scanIndexForward?: boolean;\n}\n\nexport interface DynamoDBGetItemOptions extends AwsCommandOptions {\n tableName: string;\n key: string;\n}\n\n// SQS types\nexport interface SQSQueue {\n QueueUrl: string;\n}\n\nexport interface SQSListQueuesOptions extends AwsCommandOptions {\n queueNamePrefix?: string;\n}\n\nexport interface SQSGetQueueAttributesOptions extends AwsCommandOptions {\n queueUrl: string;\n}\n\nexport interface SQSReceiveMessageOptions extends AwsCommandOptions {\n queueUrl: string;\n maxNumberOfMessages?: number;\n visibilityTimeout?: number;\n}\n\nexport interface SQSPurgeQueueOptions extends AwsCommandOptions {\n queueUrl: string;\n}\n\n// AWS Profile\nexport interface AwsProfile {\n name: string;\n source: \"config\" | \"credentials\";\n region?: string;\n sso_start_url?: string;\n}\n\n// Validation types\nexport interface AwsValidationResult {\n success: boolean;\n cliAvailable: boolean;\n cliVersion?: string;\n profiles: AwsProfile[];\n}\n\n/**\n * Parse AWS CLI error messages into user-friendly descriptions\n */\nfunction parseAwsError(\n stderr: string,\n service: string,\n command: string,\n): string {\n if (stderr.includes(\"ExpiredToken\") || stderr.includes(\"Token has expired\")) {\n return \"AWS credentials have expired. Run 'aws sso login' or refresh your credentials.\";\n }\n if (\n stderr.includes(\"NoCredentialProviders\") ||\n stderr.includes(\"Unable to locate credentials\")\n ) {\n return \"No AWS credentials found. Configure credentials with 'aws configure' or 'aws sso login'.\";\n }\n if (stderr.includes(\"AccessDenied\") || stderr.includes(\"Access Denied\")) {\n return `Access denied for ${service}:${command}. Check your IAM permissions.`;\n }\n if (stderr.includes(\"ResourceNotFoundException\")) {\n return `Resource not found. Check that the specified resource exists in the correct region.`;\n }\n if (stderr.includes(\"ValidationException\")) {\n const match = stderr.match(/ValidationException[^:]*:\\s*(.+)/);\n return match\n ? `Validation error: ${match[1].trim()}`\n : \"Validation error in request parameters.\";\n }\n if (\n stderr.includes(\"ThrottlingException\") ||\n stderr.includes(\"Rate exceeded\")\n ) {\n return \"AWS API rate limit exceeded. Wait a moment and try again.\";\n }\n if (stderr.includes(\"InvalidParameterValue\")) {\n const match = stderr.match(/InvalidParameterValue[^:]*:\\s*(.+)/);\n return match\n ? `Invalid parameter: ${match[1].trim()}`\n : \"Invalid parameter value provided.\";\n }\n return stderr.trim();\n}\n\n/**\n * Parse relative time strings like 'now-1h' to Unix timestamps\n */\nfunction parseRelativeTime(timeStr: string): number {\n const now = Date.now();\n\n if (timeStr === \"now\") {\n return now;\n }\n\n // Handle relative time like 'now-15m', 'now-1h', 'now-1d'\n const relativeMatch = timeStr.match(/^now-(\\d+)([smhd])$/);\n if (relativeMatch) {\n const value = parseInt(relativeMatch[1], 10);\n const unit = relativeMatch[2];\n const multipliers: Record<string, number> = {\n s: 1000,\n m: 60 * 1000,\n h: 60 * 60 * 1000,\n d: 24 * 60 * 60 * 1000,\n };\n return now - value * multipliers[unit];\n }\n\n // Handle ISO 8601 format\n const parsed = Date.parse(timeStr);\n if (!isNaN(parsed)) {\n return parsed;\n }\n\n // Default to the current time if parsing fails\n return now;\n}\n\n/**\n * Execute an AWS CLI command and return parsed JSON output\n */\nexport async function executeAwsCommand<T>(\n service: string,\n command: string,\n args: string[],\n options: AwsCommandOptions = {},\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<T>> {\n const fullArgs = [service, command, ...args, \"--output\", \"json\"];\n\n if (options.profile) {\n fullArgs.push(\"--profile\", options.profile);\n }\n if (options.region) {\n fullArgs.push(\"--region\", options.region);\n }\n\n logger.info(`Executing: aws ${fullArgs.join(\" \")}`);\n\n return new Promise((resolve) => {\n const proc = spawn(\"aws\", fullArgs);\n let stdout = \"\";\n let stderr = \"\";\n\n proc.stdout.on(\"data\", (data) => {\n stdout += data.toString();\n });\n proc.stderr.on(\"data\", (data) => {\n stderr += data.toString();\n });\n\n proc.on(\"close\", (code) => {\n if (code !== 0) {\n logger.error(`AWS CLI error: ${stderr}`);\n resolve({\n success: false,\n error: parseAwsError(stderr, service, command),\n });\n return;\n }\n\n // Handle empty output (some commands return nothing on success)\n if (!stdout.trim()) {\n resolve({ success: true });\n return;\n }\n\n try {\n const data = JSON.parse(stdout) as T;\n resolve({ success: true, data });\n } catch {\n // Some commands return plain text\n resolve({ success: true, data: stdout.trim() as unknown as T });\n }\n });\n\n proc.on(\"error\", (error) => {\n if (error.message.includes(\"ENOENT\")) {\n resolve({\n success: false,\n error:\n \"AWS CLI not found. Install it from https://aws.amazon.com/cli/\",\n });\n } else {\n resolve({ success: false, error: error.message });\n }\n });\n });\n}\n\n/**\n * Check if AWS CLI is available and get its version\n */\nasync function checkAwsCliVersion(): Promise<{\n available: boolean;\n version?: string;\n}> {\n return new Promise((resolve) => {\n const proc = spawn(\"aws\", [\"--version\"]);\n let stdout = \"\";\n\n proc.stdout.on(\"data\", (data) => {\n stdout += data.toString();\n });\n\n proc.on(\"close\", (code) => {\n if (code === 0) {\n // Output is like \"aws-cli/2.15.0 Python/3.11.6 Darwin/23.2.0 source/arm64\"\n const match = stdout.match(/aws-cli\\/([\\d.]+)/);\n resolve({\n available: true,\n version: match ? match[1] : stdout.trim(),\n });\n } else {\n resolve({ available: false });\n }\n });\n\n proc.on(\"error\", () => {\n resolve({ available: false });\n });\n });\n}\n\n/**\n * Validate AWS setup without making API calls\n */\nexport async function validateAwsSetup(): Promise<AwsValidationResult> {\n const cliCheck = await checkAwsCliVersion();\n const profilesResult = await listAwsProfiles();\n\n return {\n cliAvailable: cliCheck.available,\n cliVersion: cliCheck.version,\n profiles: profilesResult.success ? (profilesResult.data ?? []) : [],\n success: cliCheck.available,\n };\n}\n\n/**\n * List available AWS profiles from ~/.aws/config and ~/.aws/credentials\n */\nexport async function listAwsProfiles(\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<AwsProfile[]>> {\n const profiles: AwsProfile[] = [];\n const homeDir = os.homedir();\n\n try {\n // Parse ~/.aws/config\n const configPath = path.join(homeDir, \".aws\", \"config\");\n try {\n const configContent = await fs.readFile(configPath, \"utf-8\");\n const profileRegex = /\\[profile\\s+([^\\]]+)\\]|\\[default\\]/g;\n let match;\n while ((match = profileRegex.exec(configContent)) !== null) {\n const name = match[1] || \"default\";\n profiles.push({\n name,\n source: \"config\",\n });\n }\n logger.info(`Found ${profiles.length} profiles in config`);\n } catch {\n logger.info(\"No ~/.aws/config file found\");\n }\n\n // Parse ~/.aws/credentials\n const credentialsPath = path.join(homeDir, \".aws\", \"credentials\");\n try {\n const credentialsContent = await fs.readFile(credentialsPath, \"utf-8\");\n const profileRegex = /\\[([^\\]]+)\\]/g;\n let match;\n while ((match = profileRegex.exec(credentialsContent)) !== null) {\n const name = match[1];\n // Only add if not already in the list\n if (!profiles.find((p) => p.name === name)) {\n profiles.push({\n name,\n source: \"credentials\",\n });\n }\n }\n logger.info(`Total profiles after credentials: ${profiles.length}`);\n } catch {\n logger.info(\"No ~/.aws/credentials file found\");\n }\n\n return { success: true, data: profiles };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown error\";\n logger.error(`Error listing profiles: ${errorMessage}`);\n return { success: false, error: errorMessage };\n }\n}\n\n// Step Functions operations\nexport async function listStepFunctionExecutions(\n options: StepFunctionsListExecutionsOptions,\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<{ executions: StepFunctionExecution[] }>> {\n const args = [\"--state-machine-arn\", options.stateMachineArn];\n if (options.statusFilter) {\n args.push(\"--status-filter\", options.statusFilter);\n }\n if (options.maxResults) {\n args.push(\"--max-results\", String(options.maxResults));\n }\n\n return executeAwsCommand(\n \"stepfunctions\",\n \"list-executions\",\n args,\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n\nexport async function stopStepFunctionExecution(\n options: StepFunctionsStopExecutionOptions,\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<{ stopDate: string }>> {\n const args = [\"--execution-arn\", options.executionArn];\n if (options.cause) {\n args.push(\"--cause\", options.cause);\n }\n\n return executeAwsCommand(\n \"stepfunctions\",\n \"stop-execution\",\n args,\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n\n// Lambda operations\nexport async function listLambdaFunctions(\n options: LambdaListFunctionsOptions = {},\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<{ Functions: LambdaFunction[] }>> {\n const args: string[] = [];\n if (options.maxResults) {\n args.push(\"--max-items\", String(options.maxResults));\n }\n\n const result = await executeAwsCommand<{ Functions: LambdaFunction[] }>(\n \"lambda\",\n \"list-functions\",\n args,\n { profile: options.profile, region: options.region },\n logger,\n );\n\n // Filter by prefix if specified\n if (result.success && result.data && options.functionNamePrefix) {\n result.data.Functions = result.data.Functions.filter((f) =>\n f.FunctionName.startsWith(options.functionNamePrefix!),\n );\n }\n\n return result;\n}\n\nexport async function getLambdaFunction(\n options: LambdaGetFunctionOptions,\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<{ Configuration: LambdaFunction }>> {\n return executeAwsCommand(\n \"lambda\",\n \"get-function\",\n [\"--function-name\", options.functionName],\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n\n// CloudWatch Logs operations\nexport async function filterLogEvents(\n options: CloudWatchLogsFilterOptions,\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<{ events: LogEvent[] }>> {\n const args = [\"--log-group-name\", options.logGroupName];\n\n if (options.filterPattern) {\n args.push(\"--filter-pattern\", options.filterPattern);\n }\n if (options.startTime) {\n const startMs = parseRelativeTime(options.startTime);\n args.push(\"--start-time\", String(startMs));\n }\n if (options.endTime) {\n const endMs = parseRelativeTime(options.endTime);\n args.push(\"--end-time\", String(endMs));\n }\n if (options.limit) {\n args.push(\"--limit\", String(options.limit));\n }\n\n return executeAwsCommand(\n \"logs\",\n \"filter-log-events\",\n args,\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n\n// S3 operations\nexport async function listS3Objects(\n options: S3ListObjectsOptions,\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<{ Contents: S3Object[] }>> {\n const args = [\"--bucket\", options.bucket];\n if (options.prefix) {\n args.push(\"--prefix\", options.prefix);\n }\n if (options.maxResults) {\n args.push(\"--max-items\", String(options.maxResults));\n }\n\n return executeAwsCommand(\n \"s3api\",\n \"list-objects-v2\",\n args,\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n\n// CloudFormation operations\nexport async function describeStack(\n options: CloudFormationDescribeStackOptions,\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<{ Stacks: CloudFormationStack[] }>> {\n return executeAwsCommand(\n \"cloudformation\",\n \"describe-stacks\",\n [\"--stack-name\", options.stackName],\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n\n// DynamoDB operations\nexport async function describeDynamoDBTable(\n options: DynamoDBDescribeTableOptions,\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<{ Table: Record<string, unknown> }>> {\n return executeAwsCommand(\n \"dynamodb\",\n \"describe-table\",\n [\"--table-name\", options.tableName],\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n\nexport async function scanDynamoDB(\n options: DynamoDBScanOptions,\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<{ Items: Record<string, unknown>[] }>> {\n const args = [\"--table-name\", options.tableName];\n if (options.filterExpression) {\n args.push(\"--filter-expression\", options.filterExpression);\n }\n if (options.expressionAttributeValues) {\n args.push(\n \"--expression-attribute-values\",\n options.expressionAttributeValues,\n );\n }\n if (options.limit) {\n args.push(\"--limit\", String(options.limit));\n }\n\n return executeAwsCommand(\n \"dynamodb\",\n \"scan\",\n args,\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n\nexport async function queryDynamoDB(\n options: DynamoDBQueryOptions,\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<{ Items: Record<string, unknown>[] }>> {\n const args = [\n \"--table-name\",\n options.tableName,\n \"--key-condition-expression\",\n options.keyConditionExpression,\n \"--expression-attribute-values\",\n options.expressionAttributeValues,\n ];\n if (options.indexName) {\n args.push(\"--index-name\", options.indexName);\n }\n if (options.filterExpression) {\n args.push(\"--filter-expression\", options.filterExpression);\n }\n if (options.limit) {\n args.push(\"--limit\", String(options.limit));\n }\n if (options.scanIndexForward === false) {\n args.push(\"--no-scan-index-forward\");\n }\n\n return executeAwsCommand(\n \"dynamodb\",\n \"query\",\n args,\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n\nexport async function getDynamoDBItem(\n options: DynamoDBGetItemOptions,\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<{ Item: Record<string, unknown> }>> {\n return executeAwsCommand(\n \"dynamodb\",\n \"get-item\",\n [\"--table-name\", options.tableName, \"--key\", options.key],\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n\n// SQS operations\nexport async function listSQSQueues(\n options: SQSListQueuesOptions = {},\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<{ QueueUrls: string[] }>> {\n const args: string[] = [];\n if (options.queueNamePrefix) {\n args.push(\"--queue-name-prefix\", options.queueNamePrefix);\n }\n\n return executeAwsCommand(\n \"sqs\",\n \"list-queues\",\n args,\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n\nexport async function getSQSQueueAttributes(\n options: SQSGetQueueAttributesOptions,\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<{ Attributes: Record<string, string> }>> {\n return executeAwsCommand(\n \"sqs\",\n \"get-queue-attributes\",\n [\"--queue-url\", options.queueUrl, \"--attribute-names\", \"All\"],\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n\nexport async function receiveSQSMessage(\n options: SQSReceiveMessageOptions,\n logger: Logger = nullLogger,\n): Promise<\n AwsCommandResult<{\n Messages: Array<{\n MessageId: string;\n ReceiptHandle: string;\n Body: string;\n Attributes?: Record<string, string>;\n }>;\n }>\n> {\n const args = [\"--queue-url\", options.queueUrl];\n if (options.maxNumberOfMessages) {\n args.push(\"--max-number-of-messages\", String(options.maxNumberOfMessages));\n }\n if (options.visibilityTimeout) {\n args.push(\"--visibility-timeout\", String(options.visibilityTimeout));\n }\n args.push(\"--attribute-names\", \"All\");\n\n return executeAwsCommand(\n \"sqs\",\n \"receive-message\",\n args,\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n\nexport async function purgeSQSQueue(\n options: SQSPurgeQueueOptions,\n logger: Logger = nullLogger,\n): Promise<AwsCommandResult<void>> {\n return executeAwsCommand(\n \"sqs\",\n \"purge-queue\",\n [\"--queue-url\", options.queueUrl],\n { profile: options.profile, region: options.region },\n logger,\n );\n}\n"],"names":[],"mappings":";;;;;AAAA;;;AAGG;AAYH,MAAM,UAAU,GAAW;AACzB,IAAA,IAAI,EAAE,MAAK,EAAE,CAAC;AACd,IAAA,KAAK,EAAE,MAAK,EAAE,CAAC;CAChB;AA0LD;;AAEG;AACH,SAAS,aAAa,CACpB,MAAc,EACd,OAAe,EACf,OAAe,EAAA;AAEf,IAAA,IAAI,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,mBAAm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E,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,EACpD,MAAM,CACP;AACH;;;;"}
@@ -6,6 +6,7 @@ Access AWS services through the AWS CLI. Requires AWS CLI installed and configur
6
6
 
7
7
  | Command | Description | Required Parameters |
8
8
  |---------|-------------|---------------------|
9
+ | `validate` | Validate AWS setup (CLI availability, profiles) | - |
9
10
  | `list_profiles` | List AWS profiles | - |
10
11
  | `lambda_list_functions` | List Lambda functions | - |
11
12
  | `lambda_get_function` | Get function details | `functionName` |
@@ -23,20 +24,64 @@ Access AWS services through the AWS CLI. Requires AWS CLI installed and configur
23
24
  | `sqs_receive_message` | Peek at messages | `queueUrl` |
24
25
  | `sqs_purge_queue` | Delete all messages | `queueUrl` |
25
26
 
26
- ## Common Options
27
+ ## Parameters
27
28
 
28
- All commands accept:
29
- - `profile` - AWS profile to use
30
- - `region` - AWS region
29
+ All parameters are passed at the top level (flat structure):
30
+
31
+ | Parameter | Type | Description |
32
+ |-----------|------|-------------|
33
+ | `command` | string | Command to execute (omit for help) |
34
+ | `profile` | string | AWS profile name |
35
+ | `region` | string | AWS region (e.g., us-east-1) |
36
+ | `functionName` | string | Lambda function name |
37
+ | `functionNamePrefix` | string | Lambda function name prefix filter |
38
+ | `stateMachineArn` | string | Step Functions state machine ARN |
39
+ | `executionArn` | string | Step Functions execution ARN |
40
+ | `statusFilter` | string | Step Functions status: RUNNING, SUCCEEDED, FAILED, TIMED_OUT, ABORTED, PENDING_REDRIVE |
41
+ | `cause` | string | Cause for stopping Step Functions execution |
42
+ | `logGroupName` | string | CloudWatch Logs group name |
43
+ | `filterPattern` | string | CloudWatch Logs filter pattern |
44
+ | `startTime` | string | Start time (e.g., now-15m) |
45
+ | `endTime` | string | End time (e.g., now) |
46
+ | `bucket` | string | S3 bucket name |
47
+ | `prefix` | string | S3 object prefix filter |
48
+ | `stackName` | string | CloudFormation stack name |
49
+ | `tableName` | string | DynamoDB table name |
50
+ | `keyConditionExpression` | string | DynamoDB key condition expression |
51
+ | `expressionAttributeValues` | string | DynamoDB expression attribute values (JSON string) |
52
+ | `filterExpression` | string | DynamoDB filter expression |
53
+ | `indexName` | string | DynamoDB index name |
54
+ | `key` | string | DynamoDB item key (JSON string) |
55
+ | `scanIndexForward` | boolean | DynamoDB scan direction (true=ascending) |
56
+ | `queueUrl` | string | SQS queue URL |
57
+ | `queueNamePrefix` | string | SQS queue name prefix filter |
58
+ | `maxNumberOfMessages` | number | SQS max messages to receive |
59
+ | `visibilityTimeout` | number | SQS message visibility timeout in seconds |
60
+ | `limit` | number | Maximum number of results |
61
+ | `maxResults` | number | Maximum number of results |
31
62
 
32
63
  ## Examples
33
64
 
34
65
  ```
35
- aws("list_profiles")
36
- aws("lambda_list_functions", { region: "us-east-1", functionNamePrefix: "my-app" })
37
- aws("dynamodb_query", {
66
+ # List AWS profiles
67
+ aws({ command: "list_profiles" })
68
+
69
+ # List Lambda functions in a region
70
+ aws({ command: "lambda_list_functions", region: "us-east-1", functionNamePrefix: "my-app" })
71
+
72
+ # Query DynamoDB
73
+ aws({
74
+ command: "dynamodb_query",
38
75
  tableName: "my-table",
39
76
  keyConditionExpression: "pk = :pk",
40
77
  expressionAttributeValues: "{\":pk\":{\"S\":\"user#123\"}}"
41
78
  })
79
+
80
+ # Filter CloudWatch Logs
81
+ aws({
82
+ command: "logs_filter_log_events",
83
+ logGroupName: "/aws/lambda/my-function",
84
+ filterPattern: "ERROR",
85
+ startTime: "now-1h"
86
+ })
42
87
  ```
@@ -1,38 +1,4 @@
1
- interface AwsInput {
2
- bucket?: string;
3
- cause?: string;
4
- command?: string;
5
- endTime?: string;
6
- executionArn?: string;
7
- expressionAttributeValues?: string;
8
- filterExpression?: string;
9
- filterPattern?: string;
10
- functionName?: string;
11
- functionNamePrefix?: string;
12
- indexName?: string;
13
- key?: string;
14
- keyConditionExpression?: string;
15
- limit?: number;
16
- logGroupName?: string;
17
- maxNumberOfMessages?: number;
18
- maxResults?: number;
19
- prefix?: string;
20
- profile?: string;
21
- queueNamePrefix?: string;
22
- queueUrl?: string;
23
- region?: string;
24
- scanIndexForward?: boolean;
25
- stackName?: string;
26
- startTime?: string;
27
- stateMachineArn?: string;
28
- statusFilter?: "RUNNING" | "SUCCEEDED" | "FAILED" | "TIMED_OUT" | "ABORTED" | "PENDING_REDRIVE";
29
- tableName?: string;
30
- visibilityTimeout?: number;
31
- }
32
- export declare const awsService: import("@jaypie/fabric").Service<{
33
- command?: string;
34
- input?: AwsInput;
35
- }, string | import("./aws.js").AwsProfile[] | {
1
+ export declare const awsService: import("@jaypie/fabric").Service<Record<string, unknown>, string | import("./aws.js").AwsValidationResult | import("./aws.js").AwsProfile[] | {
36
2
  executions: import("./aws.js").StepFunctionExecution[];
37
3
  } | {
38
4
  stopDate: string;
@@ -65,7 +31,7 @@ export declare const awsService: import("@jaypie/fabric").Service<{
65
31
  }>;
66
32
  } | {
67
33
  success: boolean;
68
- } | undefined, string | import("./aws.js").AwsProfile[] | {
34
+ } | undefined, string | import("./aws.js").AwsValidationResult | import("./aws.js").AwsProfile[] | {
69
35
  executions: import("./aws.js").StepFunctionExecution[];
70
36
  } | {
71
37
  stopDate: string;
@@ -2,7 +2,7 @@ import { fabricService } from '@jaypie/fabric';
2
2
  import * as fs from 'node:fs/promises';
3
3
  import * as path from 'node:path';
4
4
  import { fileURLToPath } from 'node:url';
5
- import { purgeSQSQueue, receiveSQSMessage, getSQSQueueAttributes, listSQSQueues, getDynamoDBItem, queryDynamoDB, scanDynamoDB, describeDynamoDBTable, describeStack, listS3Objects, filterLogEvents, stopStepFunctionExecution, listStepFunctionExecutions, getLambdaFunction, listLambdaFunctions, listAwsProfiles } from './aws.js';
5
+ import { purgeSQSQueue, receiveSQSMessage, getSQSQueueAttributes, listSQSQueues, getDynamoDBItem, queryDynamoDB, scanDynamoDB, describeDynamoDBTable, describeStack, listS3Objects, filterLogEvents, stopStepFunctionExecution, listStepFunctionExecutions, getLambdaFunction, listLambdaFunctions, listAwsProfiles, validateAwsSetup } from './aws.js';
6
6
  export { executeAwsCommand } from './aws.js';
7
7
 
8
8
  /**
@@ -21,23 +21,162 @@ const awsService = fabricService({
21
21
  alias: "aws",
22
22
  description: "Access AWS services via CLI. Commands: list_profiles, lambda_*, stepfunctions_*, logs_*, s3_*, cloudformation_*, dynamodb_*, sqs_*. Call with no args for help.",
23
23
  input: {
24
+ bucket: {
25
+ description: "S3 bucket name",
26
+ required: false,
27
+ type: String,
28
+ },
29
+ cause: {
30
+ description: "Cause for stopping Step Functions execution",
31
+ required: false,
32
+ type: String,
33
+ },
24
34
  command: {
25
35
  description: "Command to execute (omit for help)",
26
36
  required: false,
27
37
  type: String,
28
38
  },
29
- input: {
30
- description: "Command parameters",
39
+ endTime: {
40
+ description: "End time for log filtering (e.g., now)",
41
+ required: false,
42
+ type: String,
43
+ },
44
+ executionArn: {
45
+ description: "Step Functions execution ARN",
46
+ required: false,
47
+ type: String,
48
+ },
49
+ expressionAttributeValues: {
50
+ description: "DynamoDB expression attribute values (JSON string)",
51
+ required: false,
52
+ type: String,
53
+ },
54
+ filterExpression: {
55
+ description: "DynamoDB filter expression",
56
+ required: false,
57
+ type: String,
58
+ },
59
+ filterPattern: {
60
+ description: "CloudWatch Logs filter pattern",
61
+ required: false,
62
+ type: String,
63
+ },
64
+ functionName: {
65
+ description: "Lambda function name",
66
+ required: false,
67
+ type: String,
68
+ },
69
+ functionNamePrefix: {
70
+ description: "Lambda function name prefix filter",
71
+ required: false,
72
+ type: String,
73
+ },
74
+ indexName: {
75
+ description: "DynamoDB index name",
76
+ required: false,
77
+ type: String,
78
+ },
79
+ key: {
80
+ description: "DynamoDB item key (JSON string)",
81
+ required: false,
82
+ type: String,
83
+ },
84
+ keyConditionExpression: {
85
+ description: "DynamoDB key condition expression",
86
+ required: false,
87
+ type: String,
88
+ },
89
+ limit: {
90
+ description: "Maximum number of results",
91
+ required: false,
92
+ type: Number,
93
+ },
94
+ logGroupName: {
95
+ description: "CloudWatch Logs group name",
96
+ required: false,
97
+ type: String,
98
+ },
99
+ maxNumberOfMessages: {
100
+ description: "SQS max messages to receive",
101
+ required: false,
102
+ type: Number,
103
+ },
104
+ maxResults: {
105
+ description: "Maximum number of results",
106
+ required: false,
107
+ type: Number,
108
+ },
109
+ prefix: {
110
+ description: "S3 object prefix filter",
111
+ required: false,
112
+ type: String,
113
+ },
114
+ profile: {
115
+ description: "AWS profile name",
116
+ required: false,
117
+ type: String,
118
+ },
119
+ queueNamePrefix: {
120
+ description: "SQS queue name prefix filter",
121
+ required: false,
122
+ type: String,
123
+ },
124
+ queueUrl: {
125
+ description: "SQS queue URL",
31
126
  required: false,
32
- type: Object,
127
+ type: String,
128
+ },
129
+ region: {
130
+ description: "AWS region (e.g., us-east-1)",
131
+ required: false,
132
+ type: String,
133
+ },
134
+ scanIndexForward: {
135
+ description: "DynamoDB scan direction (true=ascending)",
136
+ required: false,
137
+ type: Boolean,
138
+ },
139
+ stackName: {
140
+ description: "CloudFormation stack name",
141
+ required: false,
142
+ type: String,
143
+ },
144
+ startTime: {
145
+ description: "Start time for log filtering (e.g., now-15m)",
146
+ required: false,
147
+ type: String,
148
+ },
149
+ stateMachineArn: {
150
+ description: "Step Functions state machine ARN",
151
+ required: false,
152
+ type: String,
153
+ },
154
+ statusFilter: {
155
+ description: "Step Functions status filter: RUNNING, SUCCEEDED, FAILED, TIMED_OUT, ABORTED, PENDING_REDRIVE",
156
+ required: false,
157
+ type: String,
158
+ },
159
+ tableName: {
160
+ description: "DynamoDB table name",
161
+ required: false,
162
+ type: String,
163
+ },
164
+ visibilityTimeout: {
165
+ description: "SQS message visibility timeout in seconds",
166
+ required: false,
167
+ type: Number,
33
168
  },
34
169
  },
35
- service: async ({ command, input: params, }) => {
170
+ service: async (params) => {
171
+ const { command } = params;
36
172
  if (!command || command === "help") {
37
173
  return getHelp();
38
174
  }
39
- const p = params || {};
175
+ const p = params;
40
176
  switch (command) {
177
+ case "validate": {
178
+ return validateAwsSetup();
179
+ }
41
180
  case "list_profiles": {
42
181
  const result = await listAwsProfiles(log);
43
182
  if (!result.success)
@@ -254,5 +393,5 @@ const awsService = fabricService({
254
393
  },
255
394
  });
256
395
 
257
- export { awsService, describeDynamoDBTable, describeStack, filterLogEvents, getDynamoDBItem, getLambdaFunction, getSQSQueueAttributes, listAwsProfiles, listLambdaFunctions, listS3Objects, listSQSQueues, listStepFunctionExecutions, purgeSQSQueue, queryDynamoDB, receiveSQSMessage, scanDynamoDB, stopStepFunctionExecution };
396
+ export { awsService, describeDynamoDBTable, describeStack, filterLogEvents, getDynamoDBItem, getLambdaFunction, getSQSQueueAttributes, listAwsProfiles, listLambdaFunctions, listS3Objects, listSQSQueues, listStepFunctionExecutions, purgeSQSQueue, queryDynamoDB, receiveSQSMessage, scanDynamoDB, stopStepFunctionExecution, validateAwsSetup };
258
397
  //# sourceMappingURL=index.js.map