StandardAttribute

class aws_cdk.aws_cognito.StandardAttribute(*, mutable=None, required=None)

Bases: object

Standard attribute that can be marked as required or mutable.

Parameters:
  • mutable (Optional[bool]) – Specifies whether the value of the attribute can be changed. For any user pool attribute that’s mapped to an identity provider attribute, this must be set to true. Amazon Cognito updates mapped attributes when users sign in to your application through an identity provider. If an attribute is immutable, Amazon Cognito throws an error when it attempts to update the attribute. Default: true

  • required (Optional[bool]) – Specifies whether the attribute is required upon user registration. If the attribute is required and the user does not provide a value, registration or sign-in will fail. Default: false

See:

https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html#cognito-user-pools-standard-attributes

ExampleMetadata:

infused

Example:

cognito.UserPool(self, "myuserpool",
    # ...
    standard_attributes=cognito.StandardAttributes(
        fullname=cognito.StandardAttribute(
            required=True,
            mutable=False
        ),
        address=cognito.StandardAttribute(
            required=False,
            mutable=True
        )
    ),
    custom_attributes={
        "myappid": cognito.StringAttribute(min_len=5, max_len=15, mutable=False),
        "callingcode": cognito.NumberAttribute(min=1, max=3, mutable=True),
        "isEmployee": cognito.BooleanAttribute(mutable=True),
        "joinedOn": cognito.DateTimeAttribute()
    }
)

Attributes

mutable

Specifies whether the value of the attribute can be changed.

For any user pool attribute that’s mapped to an identity provider attribute, this must be set to true. Amazon Cognito updates mapped attributes when users sign in to your application through an identity provider. If an attribute is immutable, Amazon Cognito throws an error when it attempts to update the attribute.

Default:

true

required

Specifies whether the attribute is required upon user registration.

If the attribute is required and the user does not provide a value, registration or sign-in will fail.

Default:

false