LoginSignup
5
1

More than 5 years have passed since last update.

CloudFormationでCognitoのカスタム属性を使用する

Posted at

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
...
5
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
1