A professional AWS Lambda function following BuiltIn.Net.Templates standards to migrate category and subcategory IDs in job preferences from legacy IDs to new IDs.
CategoryMigrationLambda/
├── CategoryMigrationLambda/ # Main Lambda project
│ ├── Data/ # Data models and DTOs
│ ├── Services/ # Business logic services
│ ├── Extensions/ # Service collection extensions
│ ├── Function.cs # Lambda entry point
│ └── *.csproj # Project file
├── CategoryMigrationLambda.Tests/ # Unit tests
├── scripts/ # Deployment scripts
├── CategoryMigrationLambda.sln # Solution file
└── README.md # This file
cd scripts
chmod +x deploy-lambda.sh
./deploy-lambda.sh
# Migrate all preferences (dry run)
aws lambda invoke \
--function-name category-migration-lambda \
--payload '{"type":"all","dryRun":true}' \
response.json
# Migrate all preferences (actual)
aws lambda invoke \
--function-name category-migration-lambda \
--payload '{"type":"all","dryRun":false}' \
response.json
# Migrate specific user
aws lambda invoke \
--function-name category-migration-lambda \
--payload '{"type":"user","subjectId":"user-123","dryRun":true}' \
response.json
aws logs tail /aws/lambda/category-migration-lambda --follow
dotnet build
dotnet test
dotnet lambda-test-tool
- Scans DynamoDB Users table for job preferences with legacy category IDs (1000+)
- Maps legacy IDs to new IDs using embedded category mappings
- Updates preferences in batches of 25 for efficiency
- Logs all operations and errors to CloudWatch
- Supports dry run mode for safe testing
- Runtime: .NET 8
- Memory: 1024 MB
- Timeout: 15 minutes
- Table: Users (DynamoDB)
- Batch Size: 25 items per batch
Legacy Category | Legacy Subcategory | New Category | New Subcategory |
---|---|---|---|
1001 (Consulting) | null | 1 (Consulting) | null |
147 (Data + Analytics) | 508 (Analytics) | 4 (Data & Analytics) | 38 (Reporting & Insights) |
151 (Internships) | null | null | null |
- Backup your DynamoDB table before running
- Test with dry run first:
{"type":"all","dryRun":true}
- Monitor CloudWatch logs during migration
- Start with specific user:
{"type":"user","subjectId":"test-user"}
- Dependency Injection: Proper service registration and configuration
- Configuration: Environment-based settings with appsettings.json
- Logging: Structured logging with CloudWatch integration
- Error Handling: Comprehensive error tracking and reporting
- Testing: Unit tests with proper mocking and test utilities
This Lambda project is completely standalone and doesn't depend on the main usersapi project. This prevents IDE issues with nested solutions and makes it easier to manage and deploy independently.