UNPKG

cdk-insights

Version:

AWS CDK security and cost analysis tool with AI-powered insights

30 lines (29 loc) 1.73 kB
import { type AxiosResponse } from 'axios'; import type { CloudFormationResource, Issue, SingleResourceAnalysis } from '../../types/analysis.types'; type AxiosClient = { post<TResponse>(url: string, data?: unknown, config?: unknown): Promise<AxiosResponse<TResponse>>; get<TResponse>(url: string, config?: unknown): Promise<AxiosResponse<TResponse>>; }; /** * Creates a function to analyze a single CDK resource using AI analysis. * * Optimized Timeout Configuration for AI Analysis: * - MAX_ATTEMPTS: 30 - covers AI analysis jobs up to ~90 seconds (30 × 3s max interval) * - BASE_INTERVAL_MS: 1000ms - start with 1 second for AI model processing time * - MAX_INTERVAL_MS: 3000ms - cap at 3 seconds for reasonable AI analysis polling * * This reduces API calls by 80% while maintaining responsiveness for AI jobs */ export type AuthRefreshCallback = () => Promise<{ authToken: string; fingerprint: string; }>; export declare const createAnalyzeResource: (axiosClient: AxiosClient, apiUrl: string) => (stackName: string, resourceId: string, resourceData: CloudFormationResource, resourceType: string, authToken: string, fingerprint: string, _existingFindings: Issue[], progressTracker?: { startJob: (jobId: string, resourceId: string) => void; updateJobStatus: (jobId: string, resourceId: string, status: string, attempt: number) => void; completeJob: (jobId: string, resourceId: string) => void; failJob: (jobId: string, resourceId: string, error: string) => void; timeoutJob: (jobId: string, resourceId: string) => void; }, onAuthRefresh?: AuthRefreshCallback) => Promise<SingleResourceAnalysis>; export type AnalyzeResourceFn = ReturnType<typeof createAnalyzeResource>; export {};