Skip to Content
Docs

Migrate from Amazon Cognito

Move Amazon Cognito user pool profiles, groups and federated identities into Pontive with pontive migrate. Cognito exports no password hashes, so password users set a new one at their first sign-in. Then replace Amplify with pontkit.

The steps below use the pontive migrate CLI. Read Migrate to Pontive first for how runs, dry runs and matching work.

1. What moves and what does not

MovesDoes not move
Users from ListUsers: email and email_verified, phone_number and its verified flag, preferred_username, name, given_name, family_name, picture, locale, the creation date; disabled users as deactivatedPassword hashes. No Cognito API returns them, so every password user uses Forgot password at their first Pontive sign-in
Custom attributes (custom:…, without the prefix) as private_metadataTOTP and SMS factors: no secrets are exportable, so those users enroll again
Groups, as metadata.cognito_groups on each userGroups as roles or organizations: map them yourself (step 4)
Google, Sign in with Apple and OIDC identities whose userId is the provider's subjectSAML, Facebook and Login with Amazon identities, and identities linked on another attribute: those users link by verified email
The user's sub, as legacy subject and external_idUsers without an email

Since every password user resets, tell them before the cutover, from your own system: Pontive sends nothing to imported users.

2. Create the migration source

export PONTIVE_SECRET_KEY=pontive_sk_test_us_...   # an admin key of your development instance

npx pontive@latest migrate source create --name "Cognito" --type cognito   # prints msrc_...

3. Export, then dry run

The exporter uses the AWS SDK's default credentials (environment, profile or SSO) and needs cognito-idp:ListUsers, ListGroups and ListUsersInGroup on the pool. The region is AWS_REGION, else the pool id's prefix.

export AWS_PROFILE=prod

npx -p pontive@latest -p @aws-sdk/client-cognito-identity-provider \
  pontive migrate export cognito --user-pool-id us-east-1_AbC123     # writes pontive-users.ndjson
npx pontive@latest migrate import pontive-users.ndjson --source msrc_...

The AWS SDK is not installed with pontive, hence -p. The report's password users without a hash is every user who is not federated-only.

4. Map roles and connections

Identities. Map them to the Pontive app's auth connections. Import Apple identities only when your Pontive Apple connection uses the same Apple developer team, and oidc ones only for the same issuer:

npx pontive@latest migrate import pontive-users.ndjson --source msrc_... \
  --identity-connection google=app_...:google

Groups. They arrive as metadata.cognito_groups. What they become depends on what they meant:

  • Permission groups (editors, admins) become roles on the instance. Create each role on the root type (POST /v1/authz/resource-types/root/roles), then, once the users are imported, add each group's users with POST /v1/root/members, with user_id and roles. GET /v1/users?migration_source_id=msrc_... lists the imported users with their metadata. A token with no organization then carries those roles in roles, where Cognito's carried cognito:groups.
  • Customer groups in a b2b project become organizations. Append an organization line per group to the file before importing, members named by the Cognito sub, at least one of them owner:
{"kind":"organization","external_id":"acme","name":"Acme Corp","members":[{"legacy_subject":"6f1c…","roles":["owner"]},{"legacy_subject":"92ab…","roles":["admin"]}]}

5. Apply

npx pontive@latest migrate import pontive-users.ndjson --source msrc_... \
  --identity-connection google=app_...:google \
  --apply --delete-after

Failed rows: npx pontive@latest migrate records uimp_... --outcome failed.

6. Swap the SDK

Follow the React quickstart or the Next.js quickstart, then replace Amplify:

npm uninstall aws-amplify @aws-amplify/ui-react
npm install @pontive/pontkit-react
Amplify and Cognitopontkit
Amplify.configure(…) and <Authenticator><Provider domain appId signinUrl signupUrl> with <Signin /> and <Signup /> pages
signIn, signUp, confirmSignUp, resetPasswordthe flows inside <Signin /> and <Signup />, including forgot password
getCurrentUser()Auth.getAuthenticatedUser(), Auth from @pontive/oidc-client
fetchAuthSession(), tokens.accessTokenAuth.getCurrentSession()?.access_token
signOut()Auth.signOut()
aws-jwt-verify's CognitoJwtVerifierrs.requireBearer() from @pontive/pontkit-server/resource-server (Protect an API)
The cognito:groups claimthe roles and permissions claims
The Hosted UI on *.amazoncognito.comyour instance's auth domain: register the app's redirect URIs and allowed origins there

7. Cut over

Follow the cutover checklist. For Cognito in particular:

  • Export again just before switching and import into the same run with --run uimp_....
  • If your data keys users by Cognito sub, set the app's claims template to { "legacy_user_id": "{{ user.external_id }}" }.
  • Turn off the user pool's sign-ups and messages once the app is on Pontive.

8. Revert

npx pontive@latest migrate revert uimp_...          # dry run
npx pontive@latest migrate revert uimp_... --apply

Users who have signed in to Pontive since are kept and listed. See Revert.