Hi Max! Glad the tutorial helped you.

When I did the migration, I still kept the Rails users just in case. But before really using the Firebase version of my application, I moved away from Firebase entirely (multiple reasons I can explain if you like).

I’m now building the application on AWS and use Cognito to manage my users. With Cognito I could batch import the users from Rails, but I don’t have to. The more elegant solution to transition smoothly is in my opinion to use the Cognito migration trigger:

My old Rails application version as well as the new AWS application version use Cognito to authenticate users. As soon as Cognito gets an authentication request for an unknown user, it triggers a “user migration trigger”, which is a Lambda function. This function then contacts my Rails app and requests data for the user in question. If that user is in the Rails database, the Lambda function returns the user data to Cognito. Finally Cognito stores this user data in its DB and authenticates the user (as if the user had always been in Cognito).

This solution is so elegant, because migrating user data happens on a case by case basis without the user even noticing (it just takes a second longer on that first login). After the user has been migrated, it will be directly authenticated by Cognito. And since my old Rails app and the new serverless AWS app rely on Cognito for authentication, I can probably retire the Rails database in a few months (I will probably still keep a cold copy somewhere just in case).

The nice thing about Cognito is that it now handles all the tokens and token expiration as well as authorization for AWS resources.

Written by

Agile Coach, Business Innovator, Software Engineer, Musician

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store