serverless: Adding custom attribute to Cognito user pool removes Cognito trigger lambda
When changing an existing Cognito user pool, by adding a custom attribute, an existing lambda trigger is removed (even though it is still set as a trigger in serverless.yml). And by removed, I mean that in the Cognito user pool settings, it has set the trigger back to None (the lambda function itself is still deployed).
I have an existing, deployed Cognito user pool, and a lambda PostConfirmation trigger, with the event set as such:
events:
- cognitoUserPool:
pool: my_user_pool
trigger: PostConfirmation
existing: true
I update my Cognito user pool to add a custom attribute, e.g. in the Resources section I’ve updated the user pool to look like (note the Schema section at the end, which is where the custom attribute is defined):
Resources:
MyUserPool:
Type: AWS::Cognito::UserPool
Properties:
UserPoolName: my_user_pool
UsernameAttributes: # use email as username/login
- 'email'
AutoVerifiedAttributes:
- 'email'
UsernameConfiguration:
CaseSensitive: false
Policies:
PasswordPolicy:
MinimumLength: 8
RequireLowercase: true
RequireNumbers: true
RequireSymbols: false
RequireUppercase: true
AccountRecoverySetting:
RecoveryMechanisms:
- Name: verified_email
Priority: 1
VerificationMessageTemplate:
DefaultEmailOption: CONFIRM_WITH_CODE
EmailMessage: 'Thanks for signing up! Your verification code is {####}'
EmailSubject: 'Your verification code'
UserPoolTags:
NatureDose: 'true'
Schema: # Custom user attributes defined here
- AttributeDataType: String
Mutable: true
Name: appID
I then deploy, to add the custom attribute. Upon doing so, the PostConfirmation trigger for my user pool has been removed. If I go into the AWS console and restore the PostConfirmation trigger, subsequent Serverless deploys don’t remove it. This seems to be completely associated with adding custom attributes. I’ve seen this happen twice now (I actually have two custom attributes, and in both cases, it removed the trigger upon deploy of that change).
sls deploy
Deploy command output is standard successful deploy, with no specific Cognito information, etc.
Installed version
sls --version
Framework Core: 2.43.1 (standalone)
Plugin: 5.1.3
SDK: 4.2.2
Components: 3.10.0
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 9
- Comments: 22 (13 by maintainers)
Hey! just stumbled upon exactly the same issue and wanted to say that #10435 fixed that for us!
Closing, as I believe that’s addressed now.