0

我喜欢通过基于 Java 的 AWS-CDK 版本 0.24.1 创建一个认知用户池。在cdk deploy我收到错误 InvalidParameterException 期间。

服务: AWSCognitoIdentityProvider;
状态码: 400;
错误代码: InvalidParameterException: Cognito Invalid AttributeDataType input,考虑使用提供的 AttributeDataType 枚举

    CfnUserPool userPool = new CfnUserPool(this, "cognito",
    CfnUserPoolProps.builder()
        .withAdminCreateUserConfig(
            AdminCreateUserConfigProperty.builder()
                .withAllowAdminCreateUserOnly(false)
                .build())
        .withPolicies(
            PoliciesProperty.builder()
                .withPasswordPolicy(
                    PasswordPolicyProperty.builder()
                        .withMinimumLength(6)
                        .withRequireLowercase(false)
                        .withRequireNumbers(false)
                        .withRequireSymbols(false)
                        .withRequireUppercase(false)
                        .build()
                )
                .build()
        )
        .withAutoVerifiedAttributes(Arrays.asList("email"))
        .withSchema(Arrays.asList("email"))
    .build());

也许简单的字符串列表.withAutoVerifiedAttributes(Arrays.asList("email"))或者 .withSchema(Arrays.asList("email"))是错误的。但不幸的是,只有方法签名中声明的对象列表,没有具体的 typ: public CfnUserPoolProps.Builder withAutoVerifiedAttributes(@Nullable List value)

是否有一个示例片段可以使用基于 Java 的 aws-cdk 创建类似的用户池。

4

1 回答 1

0

的使用CfnUserPool.SchemaAttributeProperty.builder()解决了这个问题。我认为SchemaAttributeProperty是该方法的预期数据类型withSchema(@Nullable List< Object > value)

CfnUserPool userPool = new CfnUserPool(this, "cognito",
    CfnUserPoolProps.builder()
        .withAdminCreateUserConfig(
            AdminCreateUserConfigProperty.builder()
                .withAllowAdminCreateUserOnly(false)
                .build())
        .withPolicies(
            PoliciesProperty.builder()
                .withPasswordPolicy(
                    PasswordPolicyProperty.builder()
                        .withMinimumLength(6)
                        .withRequireLowercase(false)
                        .withRequireNumbers(false)
                        .withRequireSymbols(false)
                        .withRequireUppercase(false)
                        .build()
                )
                .build()
        )
       .withAutoVerifiedAttributes(Arrays.asList("email"))
       .withSchema(Arrays.asList(
           CfnUserPool.SchemaAttributeProperty.builder()
               .withAttributeDataType("String")
               .withName("email")
               .withRequired(true)
           .build()))
    .build());
于 2019-03-02T21:38:09.927 回答