Cognito ユーザープールを CFn で作成するとき「phone_number_verified」が指定できない

エラー、困っていたこと

以下のような CloudFormation テンプレートで Cognito ユーザープールを作成すると、エラーが発生します。

AWSTemplateFormatVersion: 2010-09-09

Resources:
  UserPool:
    Type: AWS::Cognito::UserPool
    Properties: 
      UserPoolName: test-phonenumberverified-userpool
      Schema:
        - Name: phone_number_verified
          AttributeDataType: Boolean
          DeveloperOnlyAttribute: false
          Mutable: true
          Required: false

phone_number_verified という属性を設定したいのですが、名前が長すぎるということで以下のようなエラーになっています。
エラー内容的に、詰んでるのでは?と思ったのですが…

1 validation error detected: Value 'phone_number_verified' at 'schema.1.member.name' failed to satisfy constraint: Member must have length less than or equal to 20 (Service: AWSCognitoIdentityProviderService; Status Code: 400; Error Code: InvalidParameterException; Request ID: xxxx; Proxy: null)

解決方法

phone_number_verified は明示的に指定しなくても、ユーザープール作成時にデフォルトで設定されています。

例えば以下のようにごく最低限の記載しかないテンプレートであっても、

AWSTemplateFormatVersion: 2010-09-09

Resources:
  UserPool:
    Type: AWS::Cognito::UserPool
    Properties: 
      UserPoolName: test-phonenumberverified-userpool

上記テンプレートで作成したリソースを DescribeUserPool API で参照してみると、
phone_number_verified が設定されていることが分かります。

$ aws cognito-idp describe-user-pool --user-pool-id ap-northeast-1_xxxx --no-cli-pager
{
    "UserPool": {
        "Id": "ap-northeast-1_xxxx",
        "Name": "test-phonenumberverified-userpool",
        "LastModifiedDate": "2022-12-20T14:27:08.276000+09:00",
        "CreationDate": "2022-12-20T14:27:08.276000+09:00",
        "SchemaAttributes": [
            ...
            {
                "Name": "phone_number_verified",
                "AttributeDataType": "Boolean",
                "DeveloperOnlyAttribute": false,
                "Mutable": true,
                "Required": false
            },
            ...
        ],
        "UserPoolTags": {},
        "Arn": "arn:aws:cognito-idp:ap-northeast-1:111122223333:userpool/ap-northeast-1_xxxx"
    }
}

解決方法と呼べるものか分かりませんが、検索してみると同じようなエラーに遭遇しているケースもあったので
そういった場合の助けになれれば幸いです。

phone_number_verified 以外でも nameemail など多くの属性が
デフォルトで設定されていたのですが、それらは CloudFormation で明示的に指定することが可能でした。

共同著者: 神津