Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UserPool - support mutable field to CustomAttributes #7011

Closed
markcarroll opened this issue Mar 25, 2020 · 2 comments · Fixed by #7190
Closed

UserPool - support mutable field to CustomAttributes #7011

markcarroll opened this issue Mar 25, 2020 · 2 comments · Fixed by #7190
Assignees
Labels
@aws-cdk/aws-cognito Related to Amazon Cognito effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. good first issue Related to contributions. See CONTRIBUTING.md in-progress This issue is being actively worked on.

Comments

@markcarroll
Copy link

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: Cognito@1.31.0
  • 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 Report

@markcarroll markcarroll added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 25, 2020
@nija-at nija-at added effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. good first issue Related to contributions. See CONTRIBUTING.md @aws-cdk/aws-cognito Related to Amazon Cognito and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 26, 2020
@nija-at nija-at self-assigned this Mar 26, 2020
@nija-at nija-at changed the title Cognito CustomAttributes unable to set as mutable UserPool - suppot mutable field to CustomAttributes Mar 26, 2020
@nija-at
Copy link
Contributor

nija-at commented Mar 26, 2020

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.

@nija-at nija-at changed the title UserPool - suppot mutable field to CustomAttributes UserPool - support mutable field to CustomAttributes Mar 26, 2020
@tom139
Copy link
Contributor

tom139 commented Apr 4, 2020

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.

tom139 added a commit to tom139/aws-cdk that referenced this issue Apr 6, 2020
Add properties `mutable` and `developerOnly` to all CustomAttribute
types.

fixes: aws#7011
@SomayaB SomayaB added the in-progress This issue is being actively worked on. label Apr 6, 2020
tom139 added a commit to tom139/aws-cdk that referenced this issue Apr 8, 2020
tom139 added a commit to tom139/aws-cdk that referenced this issue Apr 8, 2020
tom139 added a commit to tom139/aws-cdk that referenced this issue Apr 16, 2020
@mergify mergify bot closed this as completed in #7190 Apr 17, 2020
mergify bot added a commit that referenced this issue Apr 17, 2020
…bute (#7190)

* feat(cognito): add properties to custom attribute

Add properties `mutable` and `developerOnly` to all CustomAttribute
types.

fixes: #7011

* docs(cognito): remove reference to required property

* refactor(cognito): remove Base prefix in CustomAttribute class

fixes #7190

* fix(cognito): export CustomAttribute abstract class

fixes #7190

* docs(cognito): restore README line about required fields

fixes #7011

* fix(cognito): remove developerOnly property in CustomAttribute

fixes #7011

* refactor(cognito): remove BaseClass for custom attributes

closes #7011

* adjustments to test statements

Co-authored-by: Tommaso Panozzo <t.panozzo@miriade.it>
Co-authored-by: Niranjan Jayakar <nija@amazon.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-cognito Related to Amazon Cognito effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. good first issue Related to contributions. See CONTRIBUTING.md in-progress This issue is being actively worked on.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants