Migrating from Amazon Cognito to Keycloak: the short answer on effort
If your team runs a Cognito user pool and wants to self-host identity in infrastructure you control, the short answer is this: profiles and groups can be exported, but password hashes cannot. Amazon Cognito stores a salted hash of each password rather than the plaintext, so existing passwords cannot be pulled out of the user pool and carried into Keycloak. That means the move needs either a forced password reset for every user or a login-time migration where Keycloak accepts the password once, then stores its own hash. Plan for one of these two paths before any other design work, because it shapes what users experience on cutover day.
Effort is driven by a handful of factors rather than by user count alone. The first is how much your applications depend on Cognito-specific behavior: hosted UI pages, custom attributes, triggers (Lambda hooks) for sign-up or token issuance, and the token claims your APIs read. Each of these needs an equivalent in Keycloak, such as a theme, an authentication flow or a protocol mapper. The second is the number of app clients and redirect URIs, since each one must be recreated, tested and switched over in a planned order. The third is federated users: social or SAML identity providers linked to Cognito must be rebuilt as Keycloak identity brokering, and the linked accounts must still resolve to the same users. Confirm each of these with a written inventory of your pool before estimating anything.
Ask any partner or internal team to start with that inventory and to state which migration path they recommend and why. Ask how they will handle users who never log in during the migration window, how sessions and refresh tokens will be treated at cutover, and what they will test against your own applications. The current password policy and recovery behavior in Cognito are documented in the Amazon Cognito password documentation, which is the right reference for confirming what your users currently experience. Any effort figure you receive should trace back to that inventory, not to a generic template.
What maps cleanly from Cognito and what does not
This table compares Cognito user pool features with their nearest Keycloak equivalents and marks where the move is a configuration exercise and where it needs redesign or a migration method. Read the right-hand column as the list of items to confirm in your own environment before scoping the work. Password hashes are the main gap, because Cognito does not let you export them.
| Cognito feature | Keycloak equivalent | What to confirm in your environment |
|---|---|---|
| User pool | Realm, which holds users, clients, roles and authentication settings | Count of pools, whether any pool serves more than one application, and whether pool-level settings differ between them |
| App clients | Clients (OpenID Connect or SAML), with redirect URIs, scopes and client secrets set per client | Each app client's allowed callback and sign-out URLs, token lifetimes, and whether secrets are in use |
| Groups | Groups and client or realm roles, mapped into tokens through mappers | Whether group membership drives authorization in your apps and which claim names those apps read |
| Custom attributes | User attributes and user profile definitions, with claim mappers to tokens | Attribute names, data types, required fields and whether any attribute holds data you must not expose in tokens |
| Hosted UI and branding | Login theme and account pages, customized with Keycloak themes | Custom CSS, translated strings and any hosted UI domain that users or apps link to directly |
| Lambda triggers | Authentication flow customizations and SPI providers, which must be rebuilt and retested | Which triggers run at sign-up, sign-in, token generation or migration, and what each one calls |
| Password hashes | No direct equivalent. Cognito does not export hashes, so Keycloak cannot receive them as they are stored | Plan for a forced reset or a gradual migration at login, and confirm which users cannot be moved without a reset |
| Password policy | Password policy settings in the realm, with the policy rules set again by hand | Minimum length, character rules and history settings, since Cognito policies are not copied automatically |
| MFA (SMS, TOTP) | OTP policies, WebAuthn and passkeys, and conditional authentication flows | Which users have SMS MFA enrolled, because SMS factors and phone numbers must be re-enrolled or migrated under your own design |
| Social identity providers | Identity brokering with social providers such as Google, GitHub, Microsoft and others | Provider client IDs, redirect URIs and attribute mapping, plus whether the provider user IDs are stored in the pool |
| SAML identity providers | SAML identity providers with brokering and attribute mappers | Entity IDs, signing certificates and metadata for each external SAML provider, and any SAML apps that Cognito fronts |
| Federated users | User federation or brokering, depending on whether the directory remains the source of truth | Whether federated users keep their current sign-in path or must be linked to new Keycloak accounts |
Documented paths for moving users into Keycloak
Cognito will not reveal existing password hashes, so the import path you choose decides how passwords, profiles and groups arrive in Keycloak. The cards below cover the documented options, what each one carries across, and what your team must confirm in its own user pool before choosing.
User Storage SPI import at first lookup
Keycloak's User Storage SPI can copy users from an external store into the Keycloak database the first time each user is looked up. This lets you move applications gradually, but it requires a provider that can reach Cognito and map its attributes. Confirm that your user pool's API access, rate limits and attribute schema suit per-login reads before you commit to this path. Because Cognito will not give up password hashes, a login-time provider still needs a password plan of its own.
Keycloak developer guideRealm import and export files
Realm import and export files in JSON carry users, groups, roles and clients into Keycloak in bulk. They suit profile and group data, but a file you build from Cognito exports will not contain passwords. Plan a staging realm, load the file, and check counts of users, groups and required actions against the source pool before any application points at it. Treat the file as sensitive personal data and restrict where it is stored.
- Current Keycloak release
- 26.8.1
Admin REST API for scripted creation
The Keycloak Administration REST API lets a script create users, assign groups and set required actions such as a forced password update. Scripted creation gives you repeatable runs, retries and logs, which matter when thousands of accounts move in batches. Rate, error handling and idempotency are your responsibility, so test with a copy of the realm and confirm that a second run does not duplicate accounts.
Keycloak admin guideCognito-side export through its own APIs
Exporting users from Cognito is done through Cognito's own APIs and tools, not through Keycloak. Confirm which user attributes, custom attributes, group memberships and federated identity links your user pool exposes, and what a bulk export actually produces in your account. Cognito-side export does not return plaintext passwords, so your plan must cover what the export omits and how you will recreate it.
Cognito password docsFederated users and their identity links
Users who signed in to Cognito through a social or SAML identity provider are linked to that provider rather than to a password. Keycloak can broker the same upstream provider, but the link between the upstream subject and the user must be recreated so that accounts do not split into duplicates on first login. Test one federated user end to end before running the full batch.
How the Cognito to Keycloak cutover runs in phases
This sequence moves users and applications from Cognito to Keycloak in controlled stages, so each app is verified against a working Keycloak realm before any traffic moves and Cognito is retired only after the last application has cut over.
Inventory app clients, redirects and triggers
The team lists every Cognito app client, its allowed callback and sign-out URLs, requested OAuth scopes, token lifetimes, and any Lambda triggers that run during sign-up, sign-in or migration. Application owners confirm which clients are still in use and which can be retired. The output is a signed-off inventory that maps each client to a planned Keycloak client and a cutover wave.
Build a pilot realm with test users
Engineers create a dedicated Keycloak realm, configure a pilot OIDC client for one non-critical application, and load a small set of test accounts covering password, federated and group-based cases. They verify login, token claims, logout and refresh against the pilot client in a non-production environment. Done means the pilot app signs in and out end to end and the claim mapping matches what the application expects.
Export and import profiles and groups
Using the Cognito APIs or exports available to your account, the team extracts user profiles, custom attributes, group memberships and verification status. Because Cognito stores only salted hashes, passwords cannot be carried over, so this step moves identity data only. The data is loaded into the Keycloak realm, with attributes mapped and duplicates checked. Done means record counts and sampled attributes reconcile between the two systems.
Choose forced reset or gradual migration
The team decides how users prove their identity in Keycloak. A forced reset sends users through a password reset before first use, which needs a working email delivery path. Gradual migration uses a Keycloak user storage provider in import mode that calls Cognito at login, checks the password there, and copies the user into Keycloak. Done means the chosen method is documented per user group, and the provider or reset flow has been tested with the pilot accounts.
Run both issuers in parallel
Applications in the pilot wave are configured to accept tokens from either Cognito or Keycloak during the overlap period, so teams can compare claims, session behavior and error handling side by side. Monitoring covers failed logins, token validation errors and password reset volume. Done means the pilot wave has run without unresolved token or claim mismatches and the support team has a runbook for user questions.
Cut over app clients and redirects
Each remaining application is moved in waves: its Keycloak client is enabled with the exact redirect and logout URIs from the inventory, the application's issuer and client settings are switched, and the old Cognito client is kept available for rollback. Teams confirm sign-in, sign-out and API token validation after each switch. Done means every wave is live on Keycloak with a tested rollback path.
Handle federated users in their own step
Users who sign in through social or enterprise identity providers configured in Cognito are re-linked to Keycloak identity providers or brokered accounts. The team checks that each federated identity maps to the correct local account and that no duplicate accounts are created. Done means federated sign-in works for each provider and the mapping has been reviewed by the owners of those identity providers.
Decommission Cognito after the last app moves
Once every application has run on Keycloak through its wave and the rollback window has closed, the team disables the remaining Cognito clients, removes triggers and records the final state. Data retention and deletion obligations for the Cognito user pool are confirmed with the data owner before deletion. Done means no application still references Cognito, the decommission is recorded, and the retention decision is on file.
How login-time migration moves users without a password reset
A login-time copy only works if Keycloak can check the password against something that still knows it. Keycloak's User Storage SPI supports an import strategy that copies a user from an external store into the Keycloak database on first lookup, so applications can move over gradually. Cognito changes the picture because it stores only a salted hash of each password, as described in the Amazon Cognito password documentation, and does not return that hash. Keycloak therefore cannot copy the credential from the pool. The team must either keep the old pool available as the verifier or accept a reset for users who have not signed in again.
The usual verifier is a bridge that the team builds and tests. In illustrative terms, a custom user storage provider receives the username and password from the Keycloak login form, calls the Cognito authentication API for that user in the old pool, and imports the profile and group membership into Keycloak when the call succeeds. Because the password is only checked at Cognito, the bridge also needs to handle Cognito-specific states such as forced password change, unconfirmed accounts, MFA challenges and disabled users, and to decide how a Cognito outage affects sign-in. The bridge stays in service until every application is moved and the pool can be retired, which carries running cost and an ongoing dependency on AWS during the transition.
Before choosing this path, confirm several points with the people who own the pool and the applications. Ask whether the Cognito pool will remain available for the full transition window and who pays for it. Confirm whether the pool uses custom attributes, lambda triggers or an AWS-managed MFA setup that the bridge must reproduce. Check the account count, the sign-in volume and the number of app clients that still point at the pool. If the bridge cannot be built and tested within the agreed scope, or the business will not keep the old pool running, the realistic fallback is a forced reset with a clear communication plan, which needs its own support load and fewer users who sign in during the cutover window.
What drives the cost and duration of this move
The effort in a Cognito to Keycloak move depends less on the Keycloak install than on how many user pools, clients and integrations sit behind the existing sign-in. Most of the cost is one-time design, migration and testing, while hosting, upgrades and operations recur for as long as Keycloak runs your sign-in.
User pools and app clients
Each user pool and app client you inventory becomes a realm, client or both in Keycloak, and each needs its own mapping of scopes, token claims and redirect URIs. Teams with one pool and a few clients usually finish the inventory quickly, while a estate with several pools, shared pools and undocumented clients needs more discovery before design starts. Ask any partner to list every pool, client, domain and callback URL in writing before quoting.
Forced reset or login-time migration
A forced password reset avoids custom code but pushes every user through a reset email, which affects support volume and abandoned accounts. Login-time migration keeps users signed in without a reset, but it needs a custom User Storage SPI provider that verifies the Cognito password on first login, which adds build, test and maintenance work. Decide this early because it changes the largest build item in the project.
Keycloak developer guideLambda triggers to rewrite
Cognito Lambda triggers such as pre-authentication, post-confirmation or custom message handlers run business logic during sign-in and sign-up. Each trigger has to be re-expressed as a Keycloak authentication flow step, an event listener, a custom provider or an application-side action, and each rewrite needs its own tests. Inventory every trigger, its inputs and its side effects before estimating.
Federated identity providers
Cognito social and SAML or OIDC federation must be recreated as identity providers in Keycloak, with attribute and group mappers that match what your applications expect in tokens. Provider secrets, callback URLs and attribute names all change during cutover, so each federated login path needs its own test case. Confirm which providers are in use and which users depend on them, since federated users may not need a password migration at all.
MFA and token customizations
Cognito MFA settings, adaptive authentication and custom token claims must be recreated as Keycloak required actions, OTP or WebAuthn policies, conditional flows and protocol mappers. Users who enrolled a TOTP or SMS factor in Cognito will need to enroll again in Keycloak, which drives support work and a communication plan. Document each claim your applications read so the replacement can be checked against it.
Hosting and database design
Keycloak hosting is a recurring cost: compute, a supported production database, TLS, a reverse proxy, backups and monitoring all need owners. The high availability design also sets cost, because the supported clustered designs need a synchronously replicated database. Ask the partner to size the environment against your user count and login peaks, and to state which parts are managed by your platform team.
High availability overviewUpgrades and ongoing operations
Keycloak ships minor releases several times a year, and each upgrade needs regression testing of your redirects, tokens and custom providers. Plan for a recurring upgrade cycle and a support arrangement after cutover, either in-house or under a retainer. The cost of this recurring work is often larger than the migration itself, so ask for it as a separate line in the quote.
- Current Keycloak release
- 26.8.1
What usually goes wrong in a Cognito to Keycloak move
Will users be forced to reset their passwords when we move from Cognito to Keycloak?
They can be, and this is the most visible surprise in the move. Cognito does not export password hashes in a form Keycloak can verify, so the common options are a forced reset for every user or a gradual migration where Keycloak checks the password at login. A forced reset is simpler to plan but generates support tickets on the cutover day. Gradual migration uses the User Storage SPI import strategy, which copies a user into the Keycloak database at first lookup, so users keep their passwords when they sign in. Prevention: decide the approach before cutover, announce it to users in advance, and confirm with your security team how long the old Cognito pool stays available for login checks.
What happens to MFA enrollments after a Cognito user moves to Keycloak?
MFA enrollments usually do not carry over automatically, so users who enrolled a TOTP app, SMS number or passkey in Cognito may face an enrollment prompt they did not expect. The exact export path for MFA factors depends on what Cognito exposes for your pool, and you should confirm that with AWS documentation and a test export before you commit to a plan. Keycloak supports OTP policies, W3C WebAuthn, passkeys and recovery codes, so the target design is clear even when the source data is not. Prevention: inventory which factors each user holds, decide which users must re-enroll, and make sure recovery codes or a verified help desk process exist before the first login on Keycloak.
Why do redirect URI mismatches break sign-in after cutover?
Keycloak compares the redirect URI in each authorization request against the list configured on the client, and any difference in scheme, host, port, path or trailing slash causes the login to fail. Cognito app clients often accumulated callback URLs for staging, old domains and local development, and those values rarely map one-to-one onto a Keycloak client. A mismatch typically shows up as an error page for only some applications, which makes it hard to diagnose under pressure. Prevention: build a table of every Cognito callback and logout URL, map each one to a Keycloak client, and test sign-in and sign-out in a staging realm before DNS or application configuration changes.
How do token audience and claim differences affect applications after the move?
Tokens issued by Keycloak do not look identical to Cognito tokens. Issuer URLs, the audience (aud) value, the client identifier claim and group or custom attributes can all differ, and an application that checks these values directly will reject tokens it previously accepted. Cognito access tokens and ID tokens also use different audience conventions, so the mapping needs to be checked per token type. Prevention: list every claim each application reads, configure protocol mappers in Keycloak to produce the same names and formats where practical, and test each API with real tokens from a Keycloak test client before cutover.
What should we do with Cognito app clients that are no longer needed?
Stale Cognito app clients left active are a quiet security risk. An old client that still has a valid callback URL or a usable secret can be used to obtain tokens after the business believes the application has moved. Once the cutover is complete, each Cognito client should be reviewed, disabled or deleted according to a documented retirement plan, and any remaining secrets should be rotated or removed. Prevention: keep a register that maps each Cognito app client to its Keycloak client and an owner, set a date for retiring the old clients, and confirm with your security team that no application still depends on them before deletion.
What account recovery paths are missing once users move to Keycloak?
Teams often discover that the password reset, account unlock or verified email flows they relied on in Cognito were configured in ways that do not carry over. If a user cannot reset a password, recover MFA or confirm an email address on the day of cutover, support load rises quickly. Keycloak provides its own email, required action and recovery settings, and these need SMTP delivery that meets your policy, including the enforced StartTLS behavior in the 26.8 upgrade notes. Prevention: document each Cognito recovery flow, rebuild it in Keycloak and test it with real mailboxes, and make sure administrators can recover access to the admin console independently of end-user flows.
Can our own team handle the cutover risks, or do we need a partner?
Your own team can handle this migration if it has someone who knows Keycloak administration, can write the export and import scripts, and can run a structured test plan. A partner is most useful when the number of applications, federated identity providers or custom hashing logic makes the test matrix large. Cost depends on the number of applications and claims to map, the MFA and recovery design you choose, the amount of staging work and how much retesting cutover requires. Ask any provider for a written scope that lists these items, the test evidence they will deliver and the rollback steps.
How do we verify that federated Cognito users still sign in correctly?
Federated users, such as those who sign in through a social provider or an external SAML or OIDC identity provider, need separate testing because their identity link to the Cognito pool does not automatically become a link in Keycloak. If the identity provider is reconfigured with a different client ID, redirect URI or attribute mapping, the user may be created as a new account and lose access to existing data. Prevention: match each federated identity to its Keycloak identity provider configuration before cutover, test with accounts from each provider, and check that account linking behaves as your policy requires.
How apps and users move between Cognito and Keycloak during the parallel run
The run starts with applications still signing in through the Cognito user pool. Each user moves into Keycloak either on first login, when the Keycloak lookup copies their profile across, or through a forced password reset. Application clients are then switched to Keycloak in waves, so each client has a single source of truth at any time. Check that every client has moved and that no user is still reaching Cognito before the user pool is retired.
Applications move to Keycloak in waves while users migrate into Keycloak on first login or reset.
What your team needs to provide for the migration
The scope of this migration depends on a short list of inputs that only your team can supply. The first is access to the Cognito user pool and every app client attached to it, with enough IAM permission to read user attributes, groups and app client settings. Without that access, the export cannot be planned, and the number of app clients determines how many redirect URI cutovers the work contains. Confirm in your own AWS account which pools exist, which app clients are active, and which of them still receive sign-in traffic, because inactive clients are often removed from scope rather than migrated.
The second group of inputs covers applications and owners. Provide a list of every application that signs users in through the pool, with its redirect URIs, logout URIs, token lifetimes and the flow it uses, and name an owner who can approve the change window and test sign-in after cutover. Each application adds a client definition in Keycloak and a test pass, so an incomplete list is the most common source of late scope growth. Also decide who holds the password handling and MFA decisions. Because Cognito does not expose password hashes, you must choose between a forced reset and a gradual migration at login, and whether users re-enroll MFA devices or keep them. Record that decision before the build starts, since it changes both the Keycloak configuration and the user communication plan.
Finally, provide the target hosting environment and test accounts. Name the cloud account, cluster or virtual machines where Keycloak will run, the database service it will use, and the network path back to any upstream identity source you keep. Provide test users for each role, group and federated identity provider that exists in the pool, including accounts that sign in with social or SAML providers. Confirm with your security team how these test accounts are created, owned and removed, because they must exist in both the old and new systems during the parallel run. Clear answers to these points let the team estimate effort against a written scope instead of discovering the gaps during cutover.
How DeployOpen scopes and delivers a Cognito to Keycloak migration
A Cognito move touches users, applications and sign-in flows at once, so the work runs in a fixed sequence from a written scope. Each card below covers one stage or commitment, from the agreed scope through cutover and any ongoing support.
Written fixed scope first
Scope, deliverables and timelines are agreed in writing before work starts, and the quote follows from that written scope. DeployOpen does not publish a price list. For a Cognito move, the scope should name every user pool, app client, identity provider and downstream application in play, plus whether password reset or gradual migration at login is chosen. Ask the partner to state which items are excluded, such as custom Lambda triggers or application code changes.
Inventory of pools, clients and users
The inventory records each user pool, app client, callback and logout URL, custom attribute, group, Lambda trigger, and federated identity provider. It also records which users have verified credentials and which accounts are federated, since those behave differently during migration. Because Cognito cannot export password hashes, this inventory decides how many users need a forced reset and how many can move at login.
Keycloak realm and client design
Design maps Cognito groups to Keycloak groups or roles, attributes to user profile fields, and app clients to Keycloak clients with matching redirect URIs and PKCE settings. The realm is built in infrastructure you control, with TLS, a reverse proxy and admin access on a separate hostname. Confirm the target Keycloak version and supported database before the build starts, using the current release and the database guide.
Production guideMigration and parallel-run testing
Migration work covers the chosen path, either a user storage provider that imports users at first login or a forced reset campaign, and the password policy mapping. Parallel-run testing signs in test accounts against both systems and checks tokens, claims, group membership, refresh behavior and logout. Applications stay pointed at Cognito until these checks pass for each app client.
Developer guideCutover support and rollback plan
Cutover moves each application's issuer, client ID, redirect URIs and secrets in waves. The plan defines how DNS or configuration changes are reversed, how sessions are handled, and who approves each wave. Keep the Cognito pool available until every application has moved and the import window has closed, so a failed wave can be rolled back quickly.
Retainers for upgrades and testing
After cutover, ongoing support, Keycloak upgrades and continuous security testing are available as retainers. Keycloak releases come on a regular minor cadence, so upgrade work recurs and should be quoted separately from the one-time migration. Ask what a retainer covers, how upgrade testing is scheduled, and what response expectations are written into it.

