CloudFormationでCognitoのカスタム属性(custom attributes)を使用したい場合があります。しかし以下のように指定するとエラーとなります。
...
UserPoolClient:
Type: AWS::Cognito::UserPoolClient
Properties:
ClientName: client
GenerateSecret: false
UserPoolId: !Ref UserPool
ReadAttributes:
- custom:private_eth_address
WriteAttributes:
- custom:private_eth_address
...
エラー内容:
The following resource(s) failed to create: [UserPoolClient]. . Rollback requested by user.
Invalid write attributes specified while creating a client (Service: AWSCognitoIdentityProvider; Status Code: 400; Error Code: InvalidParameterException
エラーがわかりにくいですが、必須書き込みパラメータが未指定の場合に発生します。なので以下のように必須書き込みパラメータ(この場合はemail)を加えれば解決します。
...
UserPoolClient:
Type: AWS::Cognito::UserPoolClient
Properties:
ClientName: client
GenerateSecret: false
UserPoolId: !Ref UserPool
ReadAttributes:
- email
- custom:private_eth_address
WriteAttributes:
- email
- custom:private_eth_address
...