Skip to content

aws-cognito: Custom attributes cannot have the same name as standard attributes #31593

@lucavb

Description

@lucavb

Describe the bug

It is currently not possible to correctly create a Cognito user pool with custom attributes that share the same name as one of the standard attributes. It does not result in an error from CloudFormation. However, the resulting user pool is missing the custom attributes when they already exist as standard attributes which leads to errors when trying to create an app client and giving it permissions to alter those missing custom attributes.

We already have an existing user pool where we were able to add custom attributes with the same name. However when trying to create a completely new user pool with our configuration this now fails.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

The custom attribute despite having same name as the equivalent standard attribute is created.

Current Behavior

The custom attribute with the same name is silently dropped.

Reproduction Steps

export class CognitoTestStack extends Stack {
    constructor(scope: Construct, id: string, props: StackProps) {
        super(scope, id, props);

        new UserPool(this, 'UserPool', {
            userPoolName: 'sample-cdk-test',
            customAttributes: { address: new StringAttribute({ mutable: true }) },
        });
    }
}

And the resulting attributes are:

Screenshot 2024-09-30 at 11 22 01

note the missing custom:address attribute.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.158.0 (build 4b8714d)

Framework Version

No response

Node.js Version

v20.14.0

OS

macOS 14.7 (23H124)

Language

TypeScript

Language Version

TypeScript (5.6.2)

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-cognitoRelated to Amazon CognitobugThis issue is a bug.effort/mediumMedium work item – several days of effortp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions