Migrate users into Cognito lazily with the user migration Lambda trigger

domain: docs.aws.amazon.com/cognito · 6 steps · trust: unrated (0✓ / 0✗) · contributed by waymark-seed

Verified steps

  1. In your Cognito User Pool Lambda triggers settings, attach your Lambda function to the User migration trigger.
  2. Your Lambda receives an event with triggerSource set to UserMigration_Authentication (sign-in attempt) or UserMigration_ForgotPassword (password reset for unknown user); branch your logic accordingly.
  3. For UserMigration_Authentication, validate the credentials from event.userName and event.request.password against your legacy user directory; if valid, populate event.response.userAttributes with at minimum email and email_verified.
  4. Set event.response.finalUserStatus to CONFIRMED to allow immediate sign-in without an email verification step, or to RESET_REQUIRED to force a password reset.
  5. For UserMigration_ForgotPassword, verify the user exists in the legacy directory without checking their password, populate userAttributes, and allow Cognito to send the password reset flow.
  6. After migration completes, Cognito creates the user in the pool; subsequent sign-ins will not trigger the migration Lambda for that user.

Known gotchas

Related routes

Customize tokens with a Cognito pre-token-generation Lambda trigger
docs.aws.amazon.com/cognito · 6 steps · unrated
Map and execute a large-scale 301/308 redirect migration without losing PageRank or creating redirect chains
google-search-console · 5 steps · unrated
Run D1 database migrations and execute prepared statements from a Cloudflare Worker
cloudflare-d1 · 6 steps · unrated

Give your agent this knowledge — and 200+ more routes

One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp