AWS Mobile Blog

New AWS Mobile Hub feature: Add an existing user pool to your Mobile Hub project

Using AWS Mobile Hub is a great way for you to get started with a mobile backend project because it abstracts away the complexity of configuring a new AWS service. It does this by defining a set of IAM policies for how your apps authenticated and unauthenticated users interact with the AWS service. Up until now, Mobile Hub only supported developers who were creating new AWS services.  Sometimes, however, you want to reuse services that you’ve defined elsewhere. For example, you might have an authentication service that’s common to all of your applications. You don’t want to set up a new authentication service for each mobile app.

With the latest updates to AWS Mobile Hub, you can add an existing Amazon Cognito user pool to your AWS Mobile Hub project from the AWS Mobile Hub console. In this article, we’ll walk through how you can accomplish this.

Start by signing in to the AWS Mobile Hub console and choose the project you’re working on. If this is a new project, follow the Getting Started instructions to finish creating the project. If you’re using the AWS Mobile command line interface (CLI), you can use awsmobile console to open the project dashboard.  Then:

  1. Scroll down to Add More Backend Features.
  2. Choose User Sign-in.

  1. Choose Email and Password.
  2. Choose Import an existing user pool.

  1. Choose the Amazon Cognito user pool that you want to import.
  2. Choose whether sign-in is optional.  If it’s Yes, this means that your app can have an experience for users who aren’t signed in.
  3. Choose Import user pool.
  4. After the user pool is imported, choose the blue banner at the top of the page to return to the project dashboard.

Download the new configuration file for your project (or run awsmobile pull if you’re using the AWS Mobile CLI), and integrate Amazon Cognito into your client application. You can find specific instructions for your platform by choosing the Integrate button in the AWS Mobile Hub console.

If you’ve created the project in the past, you can also link your project to a different Amazon Cognito user pool. To do this:

  1. Choose the User Sign-in panel within your project dashboard.
  2. Choose Email and Password.
  3. Under the Action drop-down, choose Import different user pool.
  4. Continue as before with the selection of the new user pool.

If you change the User Sign-in panel, make sure that you recompile your client app with the new configuration file.

Note that AWS Mobile Hub doesn’t remove your user pool if it’s been imported, or if it has data in it (for example, if a user has signed up). You should manually delete the user pool from the Amazon Cognito console. This has the side-effect that you’re now able to recover if you accidentally removed user sign-in from your (working) Mobile Hub project. Just import the old Amazon Cognito user pool into the project.

Nikhil Swaminathan contributed this post.  Nikhil is the product manager for AWS Mobile Hub.