[英]How to set verification attributes on AWS cognito with cloudformation?
[英]How to Set required attributes in aws cognito user pool using aws cloudformation template?
在使用 cloudformation 模板创建用户池时,我想添加以下属性(在附加的图像链接中标记)。 我在 AWS 文档中没有找到任何有用的信息。
它允许设置别名属性,如 aws cloudformation cognito 文档中所述。
有没有人尝试过这个或对此有任何想法?
我设法使用 AWS::cognito::UserPool 的架构属性完成了它:
"myApiUserPool": {
"Type": "AWS::Cognito::UserPool",
"Properties": {
"AdminCreateUserConfig": {
"AllowAdminCreateUserOnly": true
},
"Schema": [
{
"Mutable": false,
"Name": "email",
"Required": true
},
{
"Mutable": false,
"Name": "family_name",
"Required": true
},
{
"Mutable": false,
"Name": "name",
"Required": true
}
],
"AutoVerifiedAttributes": [
"email"
],
"UserPoolName": {
"Fn::Sub": "myApiUserPool${envParameter}"
}
}
}
这是 YAML 的示例。
注意:您不能只更新需要删除用户池的属性并使用新属性重新创建它(只需注释掉您的池部分并重新部署它)。 否则它会要求一个AttributeDataType
,如果你包含它,它会创建一个自定义属性而不是标准属性。
CognitoUserPool:
Type: AWS::Cognito::UserPool
Properties:
# Generate a name based on the stage
UserPoolName: ${self:custom.stage}-cfp-user-pool
AliasAttributes:
- phone_number
- email
- preferred_username
Policies:
PasswordPolicy:
MinimumLength: 8
Schema:
- Name: email
Required: true
Mutable: true
添加@jWang1 并考虑到您不想删除具有大量活动用户的用户池,但您确实需要在注册过程中添加一个参数,然后您只需向模板添加一个自定义属性并将其强制执行为需要通过您的身份验证库或自定义实现
实现这一目标的最低参数是:
UserPool:
Type: AWS::Cognito::UserPool
Properties:
Schema:
-
Name: <attr name>
AttributeDataType: Boolean | DateTime | Number | String
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.