-
Notifications
You must be signed in to change notification settings - Fork 168
Description
Summary
After the refactoring of all packages to use the new functional environment variable utilities, the EnvironmentVariablesService
class in the Commons package is no longer used anywhere in the codebase. We should remove this class and its associated files to complete the migration to the new functional approach and reduce the overall codebase complexity.
The EnvironmentVariablesService
class was the old class-based approach for reading environment variables that has been superseded by the zero-dependency functional utilities introduced in #3945.
Why is this needed?
With all Powertools packages migrated to use the new functional environment variable utilities, the EnvironmentVariablesService
class serves no purpose and adds unnecessary complexity to the codebase. Removing it will:
- Reduce bundle size - Eliminates unused code from the commons package
- Simplify maintenance - Removes code that no longer needs to be maintained or tested
- Complete the migration - Finishes the transition to the new functional approach
- Improve consistency - Ensures all packages use the same modern approach for environment variables
- Reduce cognitive load - Developers won't encounter the old deprecated pattern
Which area does this relate to?
Commons
Solution
Important
The following changes are included as reference to help you understand the refactoring. Before implementing, please make sure to check the codebase and ensure that they make sense and they are exhaustive.
The following files need to be removed or modified in the packages/commons
package:
Files to Delete
1. Delete packages/commons/src/config/EnvironmentVariablesService.ts
This file contains the main EnvironmentVariablesService
class implementation that is no longer used.
2. Delete packages/commons/tests/unit/EnvironmentVariablesService.test.ts
This file contains the unit tests for the EnvironmentVariablesService
class that will no longer be needed.
Files to Modify
1. Update packages/commons/src/index.ts
Remove the export statement for EnvironmentVariablesService
:
Current:
export { EnvironmentVariablesService } from './config/EnvironmentVariablesService.js';
After removal:
// Remove the above line entirely
Additional Considerations
- The
ConfigServiceInterface
type should be evaluated to see if it's still needed after removingEnvironmentVariablesService
Acknowledgment
- This request meets Powertools for AWS Lambda (TypeScript) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Python, Java, and .NET
Future readers
Please react with 👍 and your use case to help us understand customer demand.
Sub-issues
Metadata
Metadata
Assignees
Labels
Type
Projects
Status