- Newest
- Most votes
- Most comments
Based on your description and the code provided, there are a few potential reasons why the user is not being added to the new user pool despite the Lambda function executing successfully:
-
Required Attributes: Ensure that all required attributes for the new user pool are properly mapped in the Lambda response. Double-check that the attributes you're setting (email, family_name, given_name) match the required attributes in your new user pool configuration.
-
Error Handling: Your current error handling might be masking issues. Instead of returning the event object when an error occurs, you should throw an error or return a specific error response. This will help Cognito understand that the migration failed and prevent it from assuming success.
-
Username Handling: Make sure the 'userName' in the event matches the email address you're using to log in, as it appears you're using email as the username.
-
Custom Attributes: Verify that the custom attribute "custom:metadata" is properly defined in your new Cognito user pool before attempting to migrate users with this attribute.
-
Response Format: Ensure that all attribute values are strings. For example, 'email_verified' should be "true" as a string, not a boolean value.
To improve your function, consider these modifications:
- Add more detailed logging to track the flow of the function.
- Implement proper error handling that communicates failures to Cognito.
- Verify that all required attributes are being set correctly.
- Double-check that the Lambda function has the necessary permissions to interact with Cognito.
If the problem persists after making these changes, you may need to enable detailed CloudWatch logs for both the Lambda function and Cognito to get more insight into what's happening during the migration process. Also, consider temporarily removing any non-essential attributes from the migration process to isolate the issue.
Sources
Cognito Migration Trigger returns an event, but Cognito fails to create user | AWS re:Post
Migrate user Lambda trigger - Amazon Cognito
answered 2 years ago
Relevant content
asked 3 years ago
