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

Nitesh
  • 1,477
  • 5
  • 23
  • 34

2 Answers2

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).
rinde
  • 1,181
  • 1
  • 8
  • 20
-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.