/** * Stack inference utilities for discovering CloudFormation stacks * and extracting configuration from Quilt catalogs */ import { IAwsProvider, IHttpClient, StackDetails } from "../interfaces/aws-provider"; export interface QuiltCatalogConfig { region: string; apiGatewayEndpoint: string; analyticsBucket: string; serviceBucket: string; stackVersion?: string; [key: string]: unknown; } export type { StackDetails }; export interface InferredStackInfo { config: QuiltCatalogConfig; stackName: string | null; stackDetails: StackDetails; inferredVars: Record; } export interface QuiltStack { StackName: string; StackStatus: string; Outputs?: Array<{ OutputKey: string; OutputValue: string; }>; } export interface StackSummary { StackName: string; StackStatus: string; CreationTime: string; LastUpdatedTime?: string; } /** * Stack resource metadata * * Maps logical resource ID to physical resource information */ export interface StackResourceMap { [logicalId: string]: { physicalResourceId: string; resourceType: string; resourceStatus: string; }; } /** * Discovered Quilt resources from stack * * Target resources: * - BenchlingAthenaWorkgroup (AWS::Athena::WorkGroup) * - UserAthenaNonManagedRolePolicy (AWS::IAM::ManagedPolicy) * - BucketWritePolicy (AWS::IAM::ManagedPolicy) * - IcebergDatabase (AWS::Glue::Database) * - BenchlingSecret (AWS::SecretsManager::Secret) */ export interface DiscoveredQuiltResources { athenaUserWorkgroup?: string; athenaUserPolicyArn?: string; bucketWritePolicyArn?: string; icebergDatabase?: string; benchlingSecretArn?: string; } /** * Get stack resources (physical resource IDs) * * Unlike outputs (which are user-defined exports), resources are the actual * AWS resources created by the stack. * * @param region AWS region * @param stackName CloudFormation stack name or ARN * @param awsProvider Optional AWS provider for testing * @returns Stack resources with logical and physical IDs */ export declare function getStackResources(region: string, stackName: string, _awsProvider?: IAwsProvider): Promise; /** * Validate IAM role ARN format * * @param arn - ARN to validate * @returns true if valid IAM role ARN, false otherwise */ export declare function validateRoleArn(arn: string): boolean; /** * Convert a role name to a full IAM role ARN * * @param roleNameOrArn - Role name (e.g., "ReadQuiltV2-tf-rc") or existing ARN * @param account - AWS account ID * @returns Full IAM role ARN */ export declare function toRoleArn(roleNameOrArn: string, account: string): string; /** * Extract Athena workgroups, IAM policies, S3 buckets, and Secrets Manager secrets from stack resources * * Target resources: * - BenchlingAthenaWorkgroup (AWS::Athena::WorkGroup) * - UserAthenaNonManagedRolePolicy (AWS::IAM::ManagedPolicy) * - BucketWritePolicy (AWS::IAM::ManagedPolicy) * - IcebergDatabase (AWS::Glue::Database) * - BenchlingSecret (AWS::SecretsManager::Secret) * * @param resources Stack resource map from getStackResources * @param account Optional AWS account ID for converting role names to ARNs * @param region Optional AWS region for constructing Secrets Manager ARNs * @returns Discovered Quilt resources */ export declare function extractQuiltResources(resources: StackResourceMap, account?: string, region?: string): DiscoveredQuiltResources; /** * Fetch JSON from a URL using native Node.js modules */ export declare function fetchJson(url: string): Promise; /** * Try to find CloudFormation stack by searching for resource */ export declare function findStackByResource(region: string, resourceId: string): string | null; /** * Get stack outputs and parameters */ export declare function getStackDetails(region: string, stackName: string): StackDetails; /** * Get AWS account ID */ export declare function getAwsAccountId(): string | null; /** * Extract API Gateway ID from endpoint URL */ export declare function extractApiGatewayId(endpoint: string): string | null; /** * Find CloudFormation stack using API Gateway ID * @param region AWS region * @param apiGatewayId API Gateway ID to search for * @param awsProviderOrVerbose AWS provider instance or verbose boolean (for backward compatibility) * @param verbose Verbose logging flag (only used when awsProviderOrVerbose is IAwsProvider) */ export declare function findStack(region: string, apiGatewayId: string | null, awsProviderOrVerbose?: IAwsProvider | boolean, verbose?: boolean): Promise; /** * List all CloudFormation stacks in a region */ export declare function listAllStacks(region: string): StackSummary[]; /** * Check if a stack has the QuiltWebHost output (identifying it as a Quilt catalog stack) * This is the canonical way to identify Quilt stacks vs other CloudFormation stacks. */ export declare function isQuiltStack(region: string, stackName: string): boolean; /** * Find all Quilt catalog stacks in a region * Returns an array of stacks that have the QuiltWebHost output */ export declare function findAllQuiltStacks(region: string, verbose?: boolean): QuiltStack[]; /** * Build inferred configuration from stack details */ export declare function buildInferredConfig(config: QuiltCatalogConfig, stackName: string | null, stackDetails: StackDetails, region: string, accountId: string | null, catalogDomain: string): Record; /** * Options for inferStackConfig */ export interface InferStackConfigOptions { awsProvider?: IAwsProvider; httpClient?: IHttpClient; verbose?: boolean; } /** * Parse config.json and infer stack information * @param catalogUrl URL to Quilt catalog * @param optionsOrVerbose Options object or verbose boolean (for backward compatibility) */ export declare function inferStackConfig(catalogUrl: string, optionsOrVerbose?: InferStackConfigOptions | boolean): Promise; //# sourceMappingURL=stack-inference.d.ts.map