/** * Cleanup for CloudFormation stacks stuck in failed states. * * Only operates on stacks that never successfully deployed: * - ROLLBACK_FAILED -- creation failed, rollback failed * - ROLLBACK_COMPLETE -- creation failed, rollback succeeded * - DELETE_FAILED -- deletion already started * * Never touches UPDATE_ROLLBACK_FAILED (has live resources from previous deploy). */ import type { AwsProvider } from "../../aws/AwsProvider.js"; import type { DeployCallbacks } from "../../types/callbacks.js"; import { type DeleteBlockDisableTiming } from "../probes/deleteBlockProbes.js"; export interface CleanupFailedStackOptions { /** Deletion poll budget; 5 minutes by default. */ timeoutMs?: number; /** Deletion poll interval; 5 seconds by default. */ pollMs?: number; abortSignal?: AbortSignal; /** * Wait/poll bounds for the pre-flight's guard switch-off; the registry * default in production, shortened by tests. */ timing?: DeleteBlockDisableTiming; } /** * Clean up a CloudFormation stack stuck in a failed state. * Best-effort: all errors are caught and logged, never throws. * * Flow: * 1. Check stack status -- skip if not in SAFE_CLEANUP_STATES * 2. Destroy pre-flight over the stack -- every delete-refusing guard (the * RDS / DynamoDB / ELBv2 deletion-protection registry) is switched off, or * the cleanup halts with the cure; nothing is emptied or deleted on a halt * 3. Find and empty S3 buckets blocking deletion * 4. Plain DeleteStack, then poll for DELETE_COMPLETE (5min timeout, 5s interval) * 5. If DELETE_FAILED again, retry once with RetainResources over the failed * resources that are neither buckets nor of a registry type -- a retained * database, table or load balancer would be orphaned outside CloudFormation */ export declare function cleanupFailedStack(aws: AwsProvider, stackName: string, options?: CleanupFailedStackOptions, callbacks?: DeployCallbacks): Promise;