如何使用AWS CloudFormation模板设置AWS Cognito用户池中的必需属性?

Ash*_*ude 2 amazon-web-services aws-cloudformation aws-cognito

AWS Cognito控制台屏幕

在使用cloudformation模板创建用户池时,我想添加以下属性(在附加的图像链接中标记)。在AWS文档中没有发现任何有用的信息。

如aws cloudformation cognito 文档中所述,它允许设置Alias属性。

是否有人尝试过或对此有任何想法?

jWa*_*ng1 11

这是 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
Run Code Online (Sandbox Code Playgroud)


Ash*_*ude 6

我设法使用AWS :: cognito :: UserPool的schema属性完成此操作:

"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}"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

  • 谢谢你!!亚马逊需要感到羞耻的是,他们没有指定所需的属性应该具有不同的结构。我花了很多时间才找到你的例子。 (2认同)