Cloudformation: Error: длина элемента должна быть меньше или равна 20 - PullRequest
1 голос
/ 08 мая 2019

Я использую этот шаблон CloudFormation для создания пула пользователей Cognito:

{
    "AWSTemplateFormatVersion": "2010-09-09",
    "Description": "Template creates AWS Cognito UserPool.",
    "Resources": {
        "CognitoUserPool": {
            "Type": "AWS::Cognito::UserPool",
            "Properties": {
                "Policies": {
                    "PasswordPolicy": {
                        "MinimumLength": 8,
                        "RequireUppercase": true,
                        "RequireLowercase": true,
                        "RequireNumbers": true,
                        "RequireSymbols": true
                    }
                },
                "Schema": [
                    {
                        "Name": "sub",
                        "AttributeDataType": "String",
                        "DeveloperOnlyAttribute": false,
                        "Mutable": false,
                        "Required": true,
                        "StringAttributeConstraints": {
                            "MinLength": "1",
                            "MaxLength": "2048"
                        }
                    },
                    {
                        "Name": "name",
                        "AttributeDataType": "String",
                        "DeveloperOnlyAttribute": false,
                        "Mutable": true,
                        "Required": false,
                        "StringAttributeConstraints": {
                            "MinLength": "0",
                            "MaxLength": "2048"
                        }
                    },
                    {
                        "Name": "given_name",
                        "AttributeDataType": "String",
                        "DeveloperOnlyAttribute": false,
                        "Mutable": true,
                        "Required": false,
                        "StringAttributeConstraints": {
                            "MinLength": "0",
                            "MaxLength": "2048"
                        }
                    },
                    {
                        "Name": "family_name",
                        "AttributeDataType": "String",
                        "DeveloperOnlyAttribute": false,
                        "Mutable": true,
                        "Required": false,
                        "StringAttributeConstraints": {
                            "MinLength": "0",
                            "MaxLength": "2048"
                        }
                    },
                    {
                        "Name": "middle_name",
                        "AttributeDataType": "String",
                        "DeveloperOnlyAttribute": false,
                        "Mutable": true,
                        "Required": false,
                        "StringAttributeConstraints": {
                            "MinLength": "0",
                            "MaxLength": "2048"
                        }
                    },
                    {
                        "Name": "nickname",
                        "AttributeDataType": "String",
                        "DeveloperOnlyAttribute": false,
                        "Mutable": true,
                        "Required": false,
                        "StringAttributeConstraints": {
                            "MinLength": "0",
                            "MaxLength": "2048"
                        }
                    },
                    {
                        "Name": "preferred_username",
                        "AttributeDataType": "String",
                        "DeveloperOnlyAttribute": false,
                        "Mutable": true,
                        "Required": false,
                        "StringAttributeConstraints": {
                            "MinLength": "0",
                            "MaxLength": "2048"
                        }
                    },
                    {
                        "Name": "profile",
                        "AttributeDataType": "String",
                        "DeveloperOnlyAttribute": false,
                        "Mutable": true,
                        "Required": false,
                        "StringAttributeConstraints": {
                            "MinLength": "0",
                            "MaxLength": "2048"
                        }
                    },
                    {
                        "Name": "picture",
                        "AttributeDataType": "String",
                        "DeveloperOnlyAttribute": false,
                        "Mutable": true,
                        "Required": false,
                        "StringAttributeConstraints": {
                            "MinLength": "0",
                            "MaxLength": "2048"
                        }
                    },
                    {
                        "Name": "website",
                        "AttributeDataType": "String",
                        "DeveloperOnlyAttribute": false,
                        "Mutable": true,
                        "Required": false,
                        "StringAttributeConstraints": {
                            "MinLength": "0",
                            "MaxLength": "2048"
                        }
                    },
                    {
                        "Name": "email",
                        "AttributeDataType": "String",
                        "DeveloperOnlyAttribute": false,
                        "Mutable": true,
                        "Required": true,
                        "StringAttributeConstraints": {
                            "MinLength": "0",
                            "MaxLength": "2048"
                        }
                    },
                    {
                        "Name": "email_verified",
                        "AttributeDataType": "Boolean",
                        "DeveloperOnlyAttribute": false,
                        "Mutable": true,
                        "Required": false
                    },
                    {
                        "Name": "gender",
                        "AttributeDataType": "String",
                        "DeveloperOnlyAttribute": false,
                        "Mutable": true,
                        "Required": false,
                        "StringAttributeConstraints": {
                            "MinLength": "0",
                            "MaxLength": "2048"
                        }
                    },
                    {
                        "Name": "birthdate",
                        "AttributeDataType": "String",
                        "DeveloperOnlyAttribute": false,
                        "Mutable": true,
                        "Required": false,
                        "StringAttributeConstraints": {
                            "MinLength": "10",
                            "MaxLength": "10"
                        }
                    },
                    {
                        "Name": "zoneinfo",
                        "AttributeDataType": "String",
                        "DeveloperOnlyAttribute": false,
                        "Mutable": true,
                        "Required": false,
                        "StringAttributeConstraints": {
                            "MinLength": "0",
                            "MaxLength": "2048"
                        }
                    },
                    {
                        "Name": "locale",
                        "AttributeDataType": "String",
                        "DeveloperOnlyAttribute": false,
                        "Mutable": true,
                        "Required": false,
                        "StringAttributeConstraints": {
                            "MinLength": "0",
                            "MaxLength": "2048"
                        }
                    },
                    {
                        "Name": "phone_number",
                        "AttributeDataType": "String",
                        "DeveloperOnlyAttribute": false,
                        "Mutable": true,
                        "Required": false,
                        "StringAttributeConstraints": {
                            "MinLength": "0",
                            "MaxLength": "2048"
                        }
                    },
                    {
                        "Name": "phone_number_verified",
                        "AttributeDataType": "Boolean",
                        "DeveloperOnlyAttribute": false,
                        "Mutable": true,
                        "Required": false
                    },
                    {
                        "Name": "address",
                        "AttributeDataType": "String",
                        "DeveloperOnlyAttribute": false,
                        "Mutable": true,
                        "Required": false,
                        "StringAttributeConstraints": {
                            "MinLength": "0",
                            "MaxLength": "2048"
                        }
                    },
                    {
                        "Name": "updated_at",
                        "AttributeDataType": "Number",
                        "DeveloperOnlyAttribute": false,
                        "Mutable": true,
                        "Required": false,
                        "NumberAttributeConstraints": {
                            "MinValue": "0"
                        }
                    }
                ],
                "LambdaConfig": {},
                "AutoVerifiedAttributes": [
                    "email"
                ],
                "UsernameAttributes": [
                    "email"
                ],
                "SmsVerificationMessage": "Your verification code is {####}. ",
                "EmailVerificationMessage": "Your app verification code is {####}. ",
                "EmailVerificationSubject": "Your app verification code",
                "SmsAuthenticationMessage": "Your authentication code is {####}. ",
                "MfaConfiguration": "OFF",
                "EmailConfiguration": {},
                "UserPoolTags": {},
                "AdminCreateUserConfig": {
                    "AllowAdminCreateUserOnly": false,
                    "UnusedAccountValidityDays": 7,
                    "InviteMessageTemplate": {
                        "SMSMessage": "Your username is {username} and temporary password is {####}. ",
                        "EmailMessage": "Your username is {username} and temporary password is {####}. ",
                        "EmailSubject": "Your temporary password"
                    }
                }         
            }
        }          
    },
    "Outputs": {
        "CognitoUserPoolARN": {
            "Value": {
                "Fn::GetAtt": [
                    "CognitoUserPool",
                    "Arn"
                ]
            },
            "Export": {
                "Name": {
                    "Fn::Sub": "${AWS::StackName}-cognito-userpool-arn"
                }
            }
        }
    }
}

"Schema" - это выход текущего и рабочего пула пользователей:

aws cognito-idp describe-user-pool --user-pool-id POOL_ID

У меня есть эта ошибка при создании стека (с другим именем, конечно), даже если стек действителен:

1 обнаружена ошибка проверки: значение «phone_number_verified» в «schema.18.member.name» не удовлетворяет ограничению: длина элемента должна быть меньше или равна 20 (Служба: AWSCognitoIdentityProviderService; код состояния: 400; код ошибки: InvalidParameterException; ID запроса: ID)

phone_number_verified - логическое значение.

1 Ответ

0 голосов
/ 10 мая 2019

Подсказка в сообщении об ошибке, но я согласен, что это вводит в заблуждение. Он не упоминает, на какой Member он ссылается. Для этого API это Schema свойство, которое у вас есть выше.

Вы заметите, что у вас есть 21 атрибут под Schema. Поскольку API принимает не более 20 одновременно , вы можете удалить любой из атрибутов и повторить попытку. Я думаю, что, как только вы создадите 20 ресурсов, вы сможете добавить их обратно.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...