Aws-cdk: UserPool - support mutable field to CustomAttributes

Created on 25 Mar 2020  路  2Comments  路  Source: aws/aws-cdk

Loving the Cognito support that is coming day by day. Most of it is working well, however the custom attributes currently only allow you to create immutable custom attributes. I would like mine to be mutable but there appears to be no way to do this.

Reproduction Steps

    const userPool = new cognito.UserPool(this, userPoolName, {
      signInAliases: { email: true },
      autoVerify: { email: true, phone: true },
      userPoolName,
      passwordPolicy: {
        minLength: 8,
        requireDigits: true,
        requireLowercase: true,
        requireSymbols: false,
        requireUppercase: true,
        tempPasswordValidity: cdk.Duration.days(30),
      },
      emailSettings: {
        from: "<email>",
        replyTo: "<email>",
      },
      userVerification: {
        emailStyle: VerificationEmailStyle.CODE,
        emailBody: "Your verification code is {####}",
        emailSubject: "Your verification code",
      },
      userInvitation: {
        emailBody: "An account has been created for you. Your username is {username} and temporary password is {####}.",
        emailSubject: "Account Created",
      },
      lambdaTriggers: {
        userMigration: migrateUser,
      },
      requiredAttributes: {
        email: true,
        fullname: true,
      },
      customAttributes: {
        company: new StringAttribute({ minLen: 1, maxLen: 255 }),
        type: new StringAttribute({ maxLen: 2048 }),
        custom1: new StringAttribute({ maxLen: 2048 }),
        custom2: new StringAttribute({ maxLen: 2048 }),
      },
      selfSignUpEnabled: true,
      mfa: Mfa.OPTIONAL,
      mfaSecondFactor: {
        sms: true,
        otp: true,
      },
    });

Error Log

Custom attributes are immutable
image

Environment

  • CLI Version : 1.31.0 (build 8f3ac79)
  • Module Version: [email protected]
  • OS :
  • Language : Typescript

Other

Can we get a mutable flag added back as per the old:

    cfnUserPool.schema = [
      {
        name: "company",
        attributeDataType: "String",
        required: true,
        mutable: false,
        stringAttributeConstraints: { minLength: "1", maxLength: "1024" },
      },
      {
        name: "type",
        attributeDataType: "String",
        required: false,
        mutable: true,
        stringAttributeConstraints: { maxLength: "2048" },
      },
      {
        name: "custom1",
        attributeDataType: "String",
        required: false,
        mutable: true,
        stringAttributeConstraints: { maxLength: "2048" },
      },
      {
        name: "custom2",
        attributeDataType: "String",
        required: false,
        mutable: true,
        stringAttributeConstraints: { maxLength: "2048" },
      },
    ];

This is :bug: Bug Report

@aws-cdaws-cognito efforsmall feature-request good first issue in-progress

Most helpful comment

Thanks for filing this issue. I have re-classified this as a feature request.

The support for the Mutable property needs to be implemented.

You can work around this using property overrides via our escape hatches - https://docs.aws.amazon.com/cdk/latest/guide/cfn_layer.html#cfn_layer_raw - to directly inject this property into the CloudFormation template.

All 2 comments

Thanks for filing this issue. I have re-classified this as a feature request.

The support for the Mutable property needs to be implemented.

You can work around this using property overrides via our escape hatches - https://docs.aws.amazon.com/cdk/latest/guide/cfn_layer.html#cfn_layer_raw - to directly inject this property into the CloudFormation template.

Hi, I think the solution might be to update the ICustomAttribute interface, by adding the mutable, required and developerOnly properties, matching the ones in the AWS::Cognito::UserPool::SchemaAttribute.

I will start working tomorrow on a proposed solution.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

slipdexic picture slipdexic  路  3Comments

Kent1 picture Kent1  路  3Comments

peterdeme picture peterdeme  路  3Comments

artyom-melnikov picture artyom-melnikov  路  3Comments

eladb picture eladb  路  3Comments