Migrate users from AWS cognito to firebase?

Viewed 1414

I'm in the process of migrating users from AWS to firebase. One major issue I've hit on is resolving the users ID to their database data.

When a user logs in I create a profile for them in DynamoDB indexed against their cognito identity ID.

Unfortunately (and perhaps with good reason) Amazon does not provide a clear path to find a users identity ID without them logging in. While this is good for their privacy the flipside is when it comes time to move them to firebase I don't know what data to grab for the user from dynamodb to move over to firebase.

The long and short of it is I have all the users data but no way to connect the data with the individual user unless they login and gain access to their identity id, but I need to be able to do this to migrate them over to firebase.

I'm currently flirting with the idea of having a migration process trigger when a user logs in to create a firebase account and move their data across but at the same time this could cause issues for individual users who might encounter problems that could be caught in a mass migration.

2 Answers

Staying with UserPools

First of all regarding the following part in your question,

When a user logs in I create a profile for them in DynamoDB indexed against their cognito identity ID.

Unfortunately (and perhaps with good reason) Amazon does not provide a clear path to find a users identity ID without them logging in. While this is good for their privacy the flipside is when it comes time to move them to firebase I don't know what data to grab for the user from dynamodb to move over to firebase.

This you can achieve using the Username field which can be used as the ID for the User Identity. This way you can store the Username in DynamoDB referencing to the Cognito User in the UserPool.

Migrating from UserPools and Querying Users data

If you really plan to do the migration you can use the list_users method in AWS Boto3 SDK to list all the users in a UserPool.

response = client.list_users(
    UserPoolId='string',
    AttributesToGet=[
        'string',
    ],
    Limit=123,
    PaginationToken='string',
    Filter='string'
)
Related