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

Add support for Cognito Schema #1747

Closed
schof opened this issue Feb 12, 2019 · 6 comments · Fixed by #6487
Closed

Add support for Cognito Schema #1747

schof opened this issue Feb 12, 2019 · 6 comments · Fixed by #6487
Assignees
Labels
@aws-cdk/aws-cognito Related to Amazon Cognito effort/medium Medium work item – several days of effort feature-request A feature should be added or improved.

Comments

@schof
Copy link
Contributor

schof commented Feb 12, 2019

Add CDK support so that Schema information can be configured for UserPools. This allows one to specify additional attributes that are allowed/required for new users.

@sam-goodwin sam-goodwin added feature-request A feature should be added or improved. @aws-cdk/aws-cognito Related to Amazon Cognito labels Feb 12, 2019
@schof
Copy link
Contributor Author

schof commented Feb 13, 2019

Here is a temporary workaround for anybody looking to solve the problem now:

import { App, Stack, StackProps, Token } from '@aws-cdk/cdk'
import { CfnUserPool, CfnUserPoolClient } from '@aws-cdk/aws-cognito'

export class CognitoStack extends Stack {
  constructor(scope: App, id: string, props?: StackProps) {
    super(scope, id, props)
    /**
     * Use CfnUserPool until support is added for Schema attribute
     * https://github.com/awslabs/aws-cdk/issues/1747
     */
    const userPool = new CfnUserPool(this, 'Resource', {
      userPoolName: 'helloamplify',
      usernameAttributes: [new Token('email')],
      autoVerifiedAttributes: [new Token('email')],
      schema: [
        {
          attributeDataType: 'String',
          name: 'phone_number',
          mutable: true,
          required: true
        },
        {
          attributeDataType: 'String',
          name: 'email',
          mutable: false,
          required: true
        }
      ]
    })

    // tslint:disable:no-unused-expression
    new CfnUserPoolClient(this, 'helloamplify', {
      userPoolId: userPool.userPoolId,
      clientName: 'hello-amplify-client'
    })
  }
}

@sankeyraut
Copy link

Token constructor is private in version 0.39. Import needs to be corrected.

@sankeyraut
Copy link

sankeyraut commented Jul 10, 2019

Would this be a correct configuration ?

import { CfnUserPool, CfnUserPoolClient } from '@aws-cdk/aws-cognito'
const userPool = new CfnUserPool(this, 'Resource', {
      userPoolName: 'helloamplify',
      usernameAttributes: ['email'],
      autoVerifiedAttributes: ['email'],
      schema: [
        {
          attributeDataType: 'String',
          name: 'phone_number',
          mutable: true,
          required: true
        },
        {
          attributeDataType: 'String',
          name: 'email',
          mutable: false,
          required: true
        }
      ]
    });
    const user_client = new CfnUserPoolClient(this, 'helloamplify', {
      userPoolId: userPool.ref,      
      clientName: 'helloamplifyClient'
    });

@eladb eladb assigned eladb and unassigned eladb Aug 12, 2019
@moofish32
Copy link
Contributor

We also have hit this limitation and would like to be able to add schema as well. We went for overrides for now instead of the suggested work around above.

@SomayaB SomayaB added the in-progress This issue is being actively worked on. label Jan 21, 2020
@nija-at nija-at removed the in-progress This issue is being actively worked on. label Jan 31, 2020
@nija-at
Copy link
Contributor

nija-at commented Jan 31, 2020

I have a proposal to implement CDK APIs for Congito - aws/aws-cdk-rfcs#91 - that addresses this issue.

The RFC is in the comments period. If you'd like to see how the API is going to look and propose changes, this is your chance.

@eladb eladb assigned nija-at and unassigned nija-at and eladb Feb 3, 2020
@nija-at nija-at added the effort/medium Medium work item – several days of effort label Feb 20, 2020
@0xdevalias
Copy link
Contributor

I have a proposal to implement CDK APIs for Congito - aws/aws-cdk-rfcs#91 - that addresses this issue.

Just wanted to link to the higher level 'tracking issue' for this PR for easier cross-reference:

@mergify mergify bot closed this as completed in #6487 Mar 17, 2020
mergify bot pushed a commit that referenced this issue Mar 17, 2020
)

BREAKING CHANGE: `UserPoolAttribute` has been removed. It is no longer
required to defined a `UserPool`.

closes #1747
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/medium Medium work item – several days of effort feature-request A feature should be added or improved.
Projects
None yet
8 participants