I am trying to use an AWS Cognito User Pool for user authentication, but I can't seem to figure out how to create one from the serverless.yml
file. I know that to create other resources you do something like:
resources:
Resources:
Table:
Type: "AWS::DynamoDB::Table" # Change this to "AWS::Cognito::UserPool"?
DeletionPolicy: Retain
Properties: # Change the properties here, but to what?
AttributeDefinitions:
-
AttributeName: id
AttributeType: S
KeySchema:
-
AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: arn:aws:dynamodb:us-west-1:*:table/tablename
I am assuming that I just need to change the type to "AWS:Cognito::UserPool"
and change the properties. However, I have no idea what to change it to.
For those looking for a basic example, see the answer by @ionut. All of the configuration for the AWS::Cognito::UserPool
can be found here. As for the AWS::Cognito::UserPoolClient
, it can be found here.
It's very simple and straight forward.
All you need to do is create a few resources and then export them in from your template file.
What I do usually is first create a resource file( for eg, Cognito-user-pool.yml) and the add the necessary resource and export declaration there. After that I shall be calling the resource from my serverless.yml file ( ${ file(./cognito-user-pool.yml)}
Inside your user pool resource declaration, you would need to add definitions for
In this blog post I have explained the steps in detail and also have added a YouTube video for explaining each steps.
Blog Link : https://www.codegigs.app/how-to-cognito-user-pool-using-serverless/ Video Link : https://youtu.be/bv_imx8gfLU
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With