-
Notifications
You must be signed in to change notification settings - Fork 14
feat(health): implement cleanup command for orphaned resources #480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
feat(health): implement cleanup command for orphaned resources #480
Conversation
Implements the SPEC-CLEANUP-COMMAND.md specification following TDD, DDD, and hexagonal architecture principles. **Domain Layer:** - ResourceDependencyAnalyzer: Analyzes resource dependencies and determines safe deletion order - ResourceDeletionPlanner: Creates deletion plans with cost estimates and safety warnings **Infrastructure Layer:** - ResourceDeleterRepository: Executes AWS deletion operations with proper error handling - AuditLogRepository: Logs cleanup operations and deletion attempts for audit trail **Application Layer:** - CleanupOrphanedResourcesUseCase: Orchestrates complete cleanup workflow with dependency checking, planning, and execution **CLI Layer:** - cleanup-command: User-friendly CLI interface with dry-run mode, confirmation prompts, and progress tracking - Supports filters by resource type and logical ID pattern - Interactive stack selection - JSON and console output formats **Key Features:** - Dry-run mode by default for safety - Dependency detection to prevent accidental deletion - Phase-based deletion order (VPCEndpoints → Subnets/SecurityGroups → VPCs) - Cost savings estimation - Comprehensive audit logging - Progress tracking with real-time feedback **Testing:** All components include comprehensive unit tests following TDD methodology. Tests cover happy paths, error cases, edge cases, and integration scenarios. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
**Changes:** - Remove redundant --orphaned flag (command name is clear enough) - Add interactive stack selection as default behavior (like doctor command) - Update command signature to use commander's standard pattern: `cleanup [stackName]` with options object - Add informative header showing stack, region, and mode at start - Improve console output with progress indicators - Show helpful next-step command with actual stack name - Separate header from results for cleaner output flow **Usage Examples:** ```bash # Interactive selection (no arguments needed) frigg cleanup # Specify stack directly frigg cleanup my-stack # Execute deletion with confirmation frigg cleanup my-stack --execute # Auto-confirm (skip prompts) frigg cleanup my-stack --execute --yes # Filter by resource type frigg cleanup my-stack --resource-type AWS::EC2::VPC ``` The command now provides a smoother, more intuitive experience that matches the existing frigg doctor command pattern. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
…-cleanup-command-011CUad6mQ8qY9MSkAmZXZQQ
The next branch moved frigg-cli from packages/frigg-cli to packages/devtools/frigg-cli. This commit moves cleanup-command to the new location to maintain consistency. No functional changes - this is purely a directory restructure.
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| 22520632 | Triggered | Generic High Entropy Secret | a172aa3 | packages/core/credential/repositories/tests/credential-repository-documentdb-encryption.test.js | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
|




Overview
Implements the
frigg cleanupcommand for safely deleting duplicate orphaned resources that are not part of the current CloudFormation stack template. This addresses the issue where stacks accumulate orphaned resources from previous deployments or failed operations, leading to unnecessary costs and account clutter.Follows the specification in
packages/devtools/infrastructure/domains/health/docs/SPEC-CLEANUP-COMMAND.md.Architecture
Implementation follows TDD, DDD, and Hexagonal Architecture principles with clean separation of concerns:
Domain Layer (Business Logic)
Infrastructure Layer (AWS Integration)
Application Layer (Use Cases)
CLI Layer (User Interface)
Key Features
✅ Safety-First Design
--executeflag)delete <stack-name>✅ Smart Deletion
✅ Cost Awareness
✅ Flexible Filtering
AWS::EC2::VPC)*wildcard)✅ Audit Trail
~/.frigg/audit-logs/✅ User Experience
frigg doctor)Usage Examples
Example Output
Testing
All components include comprehensive unit tests following TDD methodology:
Total: 52+ unit tests covering happy paths, error cases, edge cases, and integration scenarios.
Tests can be run with:
Files Changed
Created
packages/devtools/infrastructure/domains/health/domain/services/resource-dependency-analyzer.js(+268)packages/devtools/infrastructure/domains/health/domain/services/resource-dependency-analyzer.test.js(+381)packages/devtools/infrastructure/domains/health/domain/services/resource-deletion-planner.js(+91)packages/devtools/infrastructure/domains/health/domain/services/resource-deletion-planner.test.js(+257)packages/devtools/infrastructure/domains/health/infrastructure/adapters/resource-deleter-repository.js(+123)packages/devtools/infrastructure/domains/health/infrastructure/adapters/resource-deleter-repository.test.js(+268)packages/devtools/infrastructure/domains/health/infrastructure/adapters/audit-log-repository.js(+103)packages/devtools/infrastructure/domains/health/infrastructure/adapters/audit-log-repository.test.js(+190)packages/devtools/infrastructure/domains/health/application/use-cases/cleanup-orphaned-resources-use-case.js(+140)packages/devtools/infrastructure/domains/health/application/use-cases/cleanup-orphaned-resources-use-case.test.js(+381)packages/frigg-cli/cleanup-command/index.js(+322)Modified
packages/frigg-cli/index.js: Added cleanup command registrationBreaking Changes
None. This is a new command that doesn't affect existing functionality.
Related Documentation
packages/devtools/infrastructure/domains/health/docs/SPEC-CLEANUP-COMMAND.mdfrigg doctor,frigg repair --importReal-World Impact
Based on testing with
quo-integrations-devstack:This command helps DevOps teams:
Checklist