Cognito UserPool YAML Schema - bashing my head against a wall

I am trying to describe a new CognitoUserPool in YAML and deploy it with Serverless. I cannot resolve this error on deploy:

An error occurred: CognitoUserPool - Invalid AttributeDataType input, consider using the provided AttributeDataType enum.

The problem is with the custom field I’m trying to specify - “slug”.

AWS docs specify that my type options here are: “Member must satisfy enum value set: [Boolean, Number, String, DateTime]”

I can’t figure out what I’m doing wrong - help!

Here is my YAML file:

Resources:
  CognitoUserPool:
    Type: AWS::Cognito::UserPool
    Properties:
      # Generate a name based on the stage
      UserPoolName: user-pool-${self:custom.stage}
      # Set email as an alias
      UsernameAttributes:
        - email
      AutoVerifiedAttributes:
        - email
      Policies:
        PasswordPolicy:
          MinimumLength: 8
      Schema:
        - Name: email
          Required: true
          Mutable: true
        - Name: slug
          Required: true
          Mutable: true
          AttributeDataType: String
          StringAttributeConstraints:
            MinLength: 6
            MaxLength: 256

I didn’t manage to reproduce this error, but I got another error while deploying your example: Required custom attributes are not supported currently..
So try this:

Resources:
  CognitoUserPool:
    Type: AWS::Cognito::UserPool
    Properties:
      # Generate a name based on the stage
      UserPoolName: user-pool-${self:custom.stage}
      # Set email as an alias
      UsernameAttributes:
        - email
      AutoVerifiedAttributes:
        - email
      Policies:
        PasswordPolicy:
          MinimumLength: 8
      Schema:
        - Name: email
          Required: true
          Mutable: true
        - Name: slug
          Mutable: true
          AttributeDataType: String
          StringAttributeConstraints:
            MinLength: 6
            MaxLength: 256

And if you still get the error, take a look at CloudFormation, find the stack there, open “Events” and find the exact original error there.

You are not able to set slug as a required, you can do that only with fields which are specified by AWS:

image

Hello, see if the AttributeDataType is not missing in the email item.

Schema:
    - Name: email
      Required: true
      Mutable: true
      AttributeDataType: String