I'm trying to create a Cognito User Pool with CloudFormation but keep getting the following error upon creation:
Required custom attributes are not supported currently. (Service: AWSCognitoIdentityProviderService; Status Code: 400; Error Code: InvalidParameterException; Request ID: d21bec3f-adca-4c38-a91a-fa59f16a2cdc; Proxy: null)
The error message says I'm trying to create custom attributes but I'm just trying to specify behaviors for standard ones e.g. email
, username
, and preferred_username
.
The AWS documentation is not helping much here. Any clue what's going on? See below my CF code:
CognitoUserPool:
Type: AWS::Cognito::UserPool
Properties:
AccountRecoverySetting: # Defines which verified available method a user can use to recover their password when they call ForgotPassword
RecoveryMechanisms:
- Name: "verified_email"
Priority: 1
AdminCreateUserConfig:
AllowAdminCreateUserOnly: False
Policies:
PasswordPolicy:
MinimumLength: 6
RequireLowercase: False
RequireNumbers: False
RequireSymbols: False
RequireUppercase: False
TemporaryPasswordValidityDays: 7
Schema:
- AttributeDataType: "String"
Mutable: False
Name: "email"
Required: True
- AttributeDataType: "String"
Mutable: False
Name: "username"
Required: True
- AttributeDataType: "String"
Mutable: True
Name: "preferred_username"
Required: True
UsernameAttributes: # This user pool property cannot be updated
- "email"
UserPoolName: !Sub "${ProjectName}-userPool-${BranchName}"
Thanks for your help, Joel
So... after reading everything more carefully, I realized
username
is kind of a strange attribute as it is not part of the list of standard attributes on the doc (here) but it is however always needed, as stated in the doc:So I took out that attribute from the schema, thinking that anyway it would be there and that I could probably not change its properties. After that, it worked properly.