8

I am trying to create aws cognito user pool using aws cdk. below is my code -

user_pool = _cognito.UserPool(
    stack,
    id="user-pool-id",
    user_pool_name="temp-user-pool",
    self_sign_up_enabled=True,
    sign_in_aliases={
        "username": False,
        "email": True
    },
    required_attributes={
        "email": True
    }   
)

I want to set "Attributes" section in User pool for email . But above code gives me this exception -

Invalid AttributeDataType input, consider using the provided AttributeDataType enum. (Service: AWSCognitoIdentityProviderService; Status Code: 400; Error Code: InvalidParameterException; Request ID:

I have tried many scenarios but it didn't work. Am I missing something here. Any help would be appreciated. Thanks! I was referring this AWS doc to create userpool - https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.aws_cognito/UserPool.html and https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.aws_cognito/RequiredAttributes.html#aws_cdk.aws_cognito.RequiredAttributes

2 Answers 2

10

According to a comment on this GitHub issue this error is thrown when an attempt is made to modify required attributes for a UserPool. This leaves you two options:

  1. Update the code such that existing attributes are not modified.
  2. Remove the UserPool and create a new one. E.g. cdk destroy followed by cdk deploy will recreate your whole stack (this is probably not what you want if your stack is in production).
-1

https://github.com/terraform-providers/terraform-provider-aws/issues/3891

Found a way to get around it in production as well, where you don't need to recreate the user pool.

1
  • which part are you referring to?
    – kewur
    Mar 10, 2022 at 3:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.