How to require email validation in Cognito through

2019-04-27 14:21发布

问题:

I think I tried all properties here:

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cognito-userpool.html

couldn't get this box checked:

My config currently:

    CognitoUserPoolGeneral:
      Type: AWS::Cognito::UserPool
      Properties:
        UserPoolName: general
        Policies:
          PasswordPolicy:
            MinimumLength: 6
            RequireLowercase: false
            RequireNumbers: false
            RequireSymbols: false
            RequireUppercase: false
        Schema:
          - AttributeDataType: String
            Name: preferredLocale
            DeveloperOnlyAttribute: false
            Mutable: true
            Required: false
        EmailVerificationMessage: "Here's your verification code: {####}. Please provide it inside the application."
        EmailVerificationSubject: "subject"

回答1:

You can add

  AutoVerifiedAttributes:
    - email

To your Properties key, like so:

  UserPool:
    Type: "AWS::Cognito::UserPool"
    Properties:
      UserPoolName: !Sub ${AuthName}-user-pool
      AutoVerifiedAttributes:
        - email
      Policies:.....

For an excellent example of a CloudFormation template that creates Cognito resources, see:

https://gist.github.com/singledigit/2c4d7232fa96d9e98a3de89cf6ebe7a5