How do I check CloudWatch logs for errors when I import users into a user pool with an AWS Lambda trigger?

3 minute read
0

I want to check for errors that are reported when I import users into a user pool with a user migration AWS Lambda trigger.

Short description

Amazon Cognito allows you to import users into an Amazon Cognito user pool with a user migration Lambda trigger. This import process receives metadata about users who try to sign in. Then, it returns user profile information from an external data source or another user pool.

For information on common errors during the import process, see How do I troubleshoot common errors with importing process in Amazon Cognito?

To check for common errors, do the following:

  1. Find the name of the Lambda trigger.
  2. Find the CloudWatch log group.
  3. Use CloudWatch log stream.

Resolution

Find the name of the Lambda trigger

Using the older Amazon Cognito interface

  1. Open the Amazon Cognito console.
  2. Choose Manage User Pools.
  3. Choose your user pool.
  4. In the navigation pane, choose Triggers under General settings.
  5. Find the User Migration section, and note the name of the Lambda function.

Using the new Amazon Cognito interface

  1. Open the Amazon Cognito console.
  2. Choose your user pool.
  3. Under the User pool properties tab, find the information for the Lambda triggers.
  4. Note the name of the Lambda function for Migrate user Lambda trigger found under the section Attached Lambda function.

Using the Lambda console

  1. Open the AWS Lambda console.
  2. Search for the Lambda trigger that you created for your import job.

Lambda migration trigger name example:

TestingMigration

Find the CloudWatch log group

  1. Open the CloudWatch console.
  2. Expand Logs in the navigation pane, and then select Log Groups.
  3. Use the Log Groups search bar functionality to look for the Lambda migration trigger name that you noted earlier.

CloudWatch log group example:

/aws/lambda/TestingMigration

Or, you can also use Lambda console directly to access the CloudWatch log groups.

Using the Lambda console

  1. Open the AWS Lambda console.
  2. Search for the Lambda trigger that you created for your import job.
  3. Under the Monitor tab, select View logs in CloudWatch.
  4. This automatically redirects you to the Amazon CloudWatch console for the Lambda trigger's CloudWatch logs.

Find the CloudWatch log stream

  1. While still in CloudWatch, select the log group that you found for your user pool during the previous steps.
  2. Select the Log Streams tab, and find the log stream.
  3. Select the log stream to check the log events for the Lambda migration import error.

CloudWatch log stream example:

[Timestamp]    START RequestId: 801399c5-b60a-40b4-ae54-f7c51c29043c Version: $LATEST
[Timestamp]    [ERROR] Runtime.UserCodeSyntaxError: Syntax error in module 'lambda_function': unexpected indent (lambda_function.py, line 31) Traceback (most recent call last):   File "/var.....
[Timestamp]    END RequestId: 801399c5-b60a-40b4-ae54-f7c51c29043c

Note: Based on this example, the error reported in CloudWatch log stream shows that there's an indentation issue in the code that's causing the Lambda trigger to fail.


Related information

Importing users into user pools with a user migration Lambda trigger
How do I troubleshoot common errors with importing process in Amazon Cognito?

AWS OFFICIAL
AWS OFFICIALUpdated a year ago