Ask Your Question
0

How can I use CloudFormation to create an AWS Cognito pool that permits sign-up through email addresses?

asked 2022-09-21 11:00:00 +0000

djk gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2022-03-12 22:00:00 +0000

ladyg gravatar image

Here are the steps to create an AWS Cognito pool with email sign-up using CloudFormation:

  1. Create a new CloudFormation stack in your AWS account.
  2. Choose the "CloudFormation Designer" option to create a visual editor.
  3. Drag and drop a new "AWS::Cognito::UserPool" resource onto the canvas.
  4. Configure the user pool resource with "Email" as a sign-up option. This can be done by adding the "Email" attribute to the "Schema" property of the resource.
  5. Add a "AWS::Cognito::UserPoolClient" resource to the canvas as a child of the user pool resource.
  6. Configure the user pool client with the appropriate settings for your application.
  7. Add a "AWS::Cognito::IdentityPool" resource to allow IAM roles to be assigned to the authenticated users.
  8. Create a CloudFormation output that exposes the user pool and user pool client ID for use in your applications.

Here's an example CloudFormation template that accomplishes this:

AWSTemplateFormatVersion: '2010-09-09'
Resources:
  MyUserPool:
    Type: 'AWS::Cognito::UserPool'
    Properties:
      Schema:
        - Name: email
          AttributeDataType: String
          Mutable: true
          Required: true
      UsernameAttributes:
        - email
      AutoVerifiedAttributes:
        - email
  MyUserPoolClient:
    Type: 'AWS::Cognito::UserPoolClient'
    Properties:
      ClientName: my-app
      UserPoolId: !Ref MyUserPool
  MyIdentityPool:
    Type: 'AWS::Cognito::IdentityPool'
    Properties:
      IdentityPoolName: my-app-identity-pool
      CognitoIdentityProviders:
        - ClientId: !Ref MyUserPoolClient
          ProviderName: !GetAtt MyUserPool.ProviderName
Outputs:
  UserPoolId:
    Value: !Ref MyUserPool
  UserPoolClientId:
    Value: !Ref MyUserPoolClient

Note: This template is just an example and may need to be adapted for your specific use case.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-09-21 11:00:00 +0000

Seen: 9 times

Last updated: Mar 12 '22