Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you migrate AWS Cognito users between user pools?

I am using AWS Cognito. I have a pretty common scenario: users can register in different roles. Depending on the role different user attributes are required, so I need to use different user pools.

Now a user wants to upgrade from role A to role B - thus I would have to move his account from one pool to another. Is this possible with AWS? The response in Can you export/migrate users out of AWS cognito, does it cause vendor lock-in? seems to indicate the opposite.

If not possible this way, what would be a viable solution to achieve requiring different user attributes depending on different user roles with AWS Cognito. (NOTE: requiring / verifying them only on the front end is not a viable solution)

like image 278
B M Avatar asked Feb 12 '17 11:02

B M


People also ask

How do I transfer a Cognito user pool from one account to another?

You can download a template . csv file for your user pool from the Amazon Cognito console. Navigate to the Users and groups tab of an existing user pool, and click the Import users button. You can then export your existing user data from your existing user directory or store into the .

Can you export users from Cognito?

Cognito does not allow a way to export users from a user pool.

How do you trigger migration in Cognito?

For details on the authentication flow with the user migration Lambda trigger, see Importing users into user pools with a user migration Lambda trigger. To migrate users from your existing user directory into Amazon Cognito user pools at sign-in, or during the forgot-password flow, use this Lambda trigger.

What is the difference between AWS Cognito user pool and identity pool?

Short description. User pools are for authentication (identity verification). With a user pool, your app users can sign in through the user pool or federate through a third-party identity provider (IdP). Identity pools are for authorization (access control).


1 Answers

I know this question is a bit dated, but it is possible that this scenario is best solved by using Groups instead of a separate user pool for each role. See here

If you reach this link to find out how to transfer users to a new pool (for instance, you needed to create a new user pool in order to change how your users log in), then there isn't a built in way to do this. However, there are solutions that you could build in order to migrate users, which is referenced here:

  1. Create your new user pool.
  2. Modify your client to do the following:

    • On failed sign in with new user pool, attempt sign in with old user pool.
    • If existing user pool sign in is successful, use the username and password that was submitted to the existing sign in to create a user on the new user pool.
    • Possibly do something to remove the user from the old user pool or mark as migrated.

enter image description here

You can export users and import them to a new user pool with a CSV file, but your users will have to change their password.

like image 81
Justin Waite Avatar answered Sep 19 '22 17:09

Justin Waite