In this video we'll learn to set up a new Cognito User Pool and a User Pool Client. This will allow us to build a React app using AWS Amplify that has signup, login, logout and API security build it which we'll be doing in the next video.

Amazon Cognito is a service that lets you add user sign-up, sign-in, and access control to your web and mobile apps quickly and easily. We'll be setting up the back end so that the next video we can create a react app with built in signup, login and authentication.

To start we need to head our serverless.yml file and to the Resources section. In here we need to add two new resources.

CognitoUserPool:
    Type: AWS::Cognito::UserPool
    Properties:
        UserPoolName: ${self:provider.stage}-user-pool
        UsernameAttributes:
            - email
        AutoVerifiedAttributes:
            - email
            
CognitoUserPoolClient:
    Type: AWS::Cognito::UserPoolClient
    Properties:
        ClientName: ${self:provider.stage}-user-pool-client
        UserPoolId:
            Ref: CognitoUserPool
        ExplicitAuthFlows:
            - ADMIN_NO_SRP_AUTH
        GenerateSecret: false

The first part of this is the user pool its self. This is what is going to contain all of the users for this app. I've used the stage to make sure I deploy a new user pool for dev, UAT and production branches.

We've also set their username to be their email address. This is probably the easiest thing to go with for now.

Next we need to make a client for that user pool. A client is just an identifier for the app that we're going to be building in the next video. You could have multiple clients if you wanted multiple apps to share the same user pool.

In this client, we're setting the UserPoolId to Ref: CognitoUserPool and this will automatically put the arn from the user pool into that field for us.

With all of this done we can deploy our new Cognito services with sls deploy. Once that is done we can head over to our AWS account and see what we've got.

If we go into the Cognito service and click Manage User Pools then we can see that we have one new pool. Clicking into that we see all of the details we expect. We can also click into App clients and see that there is a single client, named as we would expect. This has an App client id which we'll be needing for the next video where we'll be setting up our React app with AWS Amplify.