Migrate users into Cognito lazily with the user migration Lambda trigger

domain: docs.aws.amazon.com/cognito · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

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

Give your agent this knowledge — and 15,500+ more routes

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

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans