diff --git a/local-app/python-tools/gfl-resource-actions/analysis.md b/local-app/python-tools/gfl-resource-actions/analysis.md deleted file mode 100644 index 717eea6f..00000000 --- a/local-app/python-tools/gfl-resource-actions/analysis.md +++ /dev/null @@ -1,163 +0,0 @@ -# AWS Resource Management Code Analysis - -## Current Structure Analysis - -The current codebase contains several utility modules with overlapping functionality. This analysis identifies opportunities for consolidation and suggests improvements to the project structure. - -### Utility Files Overview - -1. **aws_utils.py** - - Contains AWS credential management, session handling, region detection - - Has caching mechanisms for performance optimization - - Contains partition detection logic - -2. **utils.py** - - Already marked as deprecated, imports from aws_utils.py - - Maintained for backward compatibility - -3. **partition_utils.py** - - Contains AWS partition information and utilities - - Defines constants for partition regions - - Provides functions for region/partition validation and conversion - -4. **discovery_utils.py** - - Contains pagination utilities for AWS API responses - - Provides common functions for resource discovery - - Handles tag formatting and resource state normalization - -5. **logging_setup.py** - - Contains logging configuration utilities - - Includes CSV logging functionality - - Defines context logging utilities - -6. **csv_utils.py** - - Contains utilities for CSV file operations - - Has functions for initializing and writing to CSV files - - Provides tag formatting for CSV output - -7. **config_manager.py** - - Handles configuration loading and merging - - Provides default configuration values - - Implements deep dictionary merging - -## Identified Issues - -1. **Functionality Duplication** - - AWS credential handling is split between multiple files - - Region/partition handling logic is duplicated between aws_utils.py and partition_utils.py - - CSV handling appears in both logging_setup.py and csv_utils.py - -2. **Circular Dependencies** - - logging_setup.py imports from csv_utils.py and config_manager.py - - aws_utils.py imports from partition_utils.py - - Potential for circular import issues - -3. **Inconsistent Abstractions** - - Some files mix high-level and low-level functions - - Unclear boundaries between modules - -## Consolidation Plan - -### 1. Core Utility Modules - -Restructure the utilities into these core modules: - -1. **aws_core_utils.py** - - AWS credential management - - Session handling - - Account discovery - - Move core AWS authentication functions here - -2. **region_utils.py** - - Merge partition_utils.py functionality here - - Region validation and filtering - - Partition detection and mapping - -3. **api_utils.py** - - Move pagination utilities from discovery_utils.py here - - Add general AWS API helpers - - Centralize error handling patterns - -4. **logging_utils.py** - - Keep logging configuration separated - - Remove CSV dependencies - -5. **file_utils.py** - - Consolidate CSV handling here - - Add other file operations - - Include reporting file utilities - -### 2. Implementation Strategy - -1. **Phase 1 - Core Module Creation** - - Create the consolidated modules without removing existing ones - - Redirect imports from old modules to new consolidated ones - - Add deprecation warnings to old modules - -2. **Phase 2 - Migration** - - Update imports throughout the codebase - - Ensure backward compatibility - - Add comprehensive testing - -3. **Phase 3 - Cleanup** - - Remove deprecated modules - - Update documentation - - Clean up any remaining references - -### 3. Proposed Package Structure - -``` -aws_resource_management/ -├── __init__.py -├── utils/ -│ ├── __init__.py -│ ├── aws_core_utils.py -│ ├── region_utils.py -│ ├── api_utils.py -│ ├── logging_utils.py -│ ├── file_utils.py -│ └── config_utils.py -├── cli.py -├── core.py -├── discovery.py -├── reporting.py -├── resource_registry.py -├── managers/ -│ ├── __init__.py -│ ├── base.py -│ ├── ec2.py -│ ├── ecr.py -│ ├── eks.py -│ ├── emr.py -│ └── rds.py -``` - -## Implementation Recommendations - -1. **Maintain GovCloud Support** - - Ensure all utilities properly handle different AWS partitions - - Keep partition detection logic robust - -2. **Preserve Caching Mechanisms** - - Maintain the existing caching patterns during consolidation - - Add more consistent cache invalidation - -3. **Standardize Error Handling** - - Create consistent error handling patterns across utilities - - Implement more detailed error logging - -4. **Centralize Configuration** - - Use a single approach to configuration management - - Make configuration injection more explicit - -5. **Improve Type Annotations** - - Add comprehensive typing information - - Use modern typing features like TypedDict and Protocol - -## Next Steps - -1. Create the new utility modules following the plan above -2. Write comprehensive tests for the new modules -3. Update existing code to use the new modules -4. Gradually deprecate and remove old modules -5. Update documentation to reflect the new structure