Why is the e-mail attribute defined as a Username attribute in the CloudFormation resources YML

I was just pondering the differences between UsernameAttributes and AliasAttributes, you can’t have both it seems, and as far as I understand, AliasAttributes give you a changeable attribute that you can use as a login. Moreover, this is an excerpt from the AWS document that talks about how the SignUp API works:

Call the SignUp API and pass an email address or phone number in the username parameter of the API. This API does the following:

  • If the username string is in valid email format, the user pool automatically populates the email attribute of the user with the username value.
  • If the username string is in valid phone number format, the user pool automatically populates the phone_number attribute of the user with the username value.
  • If the username string format is not in email or phone number format, the SignUp API throws an exception.

As such, if you wanted an e-mail and a preferred_username as username attributes, you’d just provide preferred_username as an AliasAttributes field and call it a day, correct? By that logic, if you wanted just the e-mail as a username attribute, you wouldn’t provide any properties. As such, the UsernameAttributes property seems to be completely useless…

My theory here is that you can either have one or the other, and you’d use UsernameAttributes if you didn’t have any aliases to give out. Am I correct?

Edit: my Serverless deploys fine if I don’t provide either, this is confusing :woozy_face:
Edit#2: seems like signing up without either UsernameAttributes or AliasAttributes does not send me a confirmation e-mail, huh.
Edit#3: that is very weird, the API reference says this If the username string is in valid email format, the user pool automatically populates the email attribute of the user with the username value. but it’s not happening in my case, these are my attributes:

[
  {
    "Name": "sub",
    "Value": "c3721ad8-7b5d-44f8-b55b-ee1ff510e45e"
  }
]

No email field which is very weird, I’ll submit a bug report on Github :woozy_face:

Hmm the Cognito options are very poorly designed. Can you link to the bug report?