Now that we’ve arrived, let’s demonstrate some of the capabilities we’ve unlocked by parallelizing our Firebase environment with our new AWS environment.
Earlier in this workshop, we served our Ionic demo app on Cloud9 using its Preview feature. Let’s now navigate back to the running app and demonstrate how we can hot switch between both our original Firebase environment, as well as our new AWS environment.
Click on the “Firebase Mode” toggle switch to turn off the Firebase environment and switch to the AWS environment:
You can tell the app is now using the AWS backend via the Amplify libraries as both the color scheme and the logo in the upper left hand corner of the app has changed:
If we modify Firebase data, we can see the changes propagate to the AWS backend by way of the Fargate service we deployed. This service can be deprecated if and when the Firebase environment is no longer desired and the data is fully in sync.
When we deployed the Firebase migrator CDK application, a Cognito User Pool was created to host our new AWS based users. However, if we have existing Firebase users and do not want to force them to reset their passwords by manually migrating to Cognito, we can leverage Cognito’s built in migration Lambda trigger capability and simply have our users login using Cognito with their Firebase credentials.
Behind the scenes, we implemented a Lambda function that performs the low level proxy authentication to Firebase Authentication using the Firebase Admin SDK. When the process completes, the same credentials are stored securely in Cognito. One added benefit of using Cognito us the ability to optionally use a username as well as email and password. By default, the user portion of the email address that was migrated is set to the username, and the user can change their preferred username if they wish.
Let’s now sign in using the email
firstname.lastname@example.org. Retrieve the Firebase Authentication password using the credentials given at the beginning of this workshop:
Once you’re signed in, you can inspect the Cognito User Pool in the AWS Console and see that the user was migrated: