In my AWS project, I use the serverless framework to deploy lambda functions and a Cognito user pool.
I want 2 of my lambda functions to be triggered by Cognito user pool events, so here is what I did:
functions: auto-move-to-user-group: handler: src/auto-move-to-user-group.handler name: auto-move-to-user-group events: - cognitoUserPool: pool: test-user-pool trigger: PostAuthentication existing: True auto-validation-user-email-modification: handler: src/auto-validation-user-email-modification.handler name: auto-validation-user-email-modification events: - cognitoUserPool: pool: test-user-pool trigger: CustomMessage existing: True resources: Resources: MyCognitoUserPool: Type: AWS::Cognito::UserPool Properties: UserPoolName: test-user-pool AutoVerifiedAttributes: - email UsernameAttributes: - email Schema: - Name: email Required: True
When I deploy using the
serverless deploy command, I sometimes got the following error:
An error occurred: AutoDashvalidationDashuserDashemailDashmodificationCustomCognitoUserPool1 - Failed to create resource. Only one request to update this UserPool can be processed at a time.
It looks like a random bug, since it doesn’t occurs everytime (happens very often, though). Also, when it occurs, it doesn’t always occurs on the same function.
Did I do something wrong? How can I fix that?
Thanks for your help.