When lambda functions are first defined with Cognito User Pool events with an existing pool, a custom lambda is created to do the work of backing up the user pool resource as defined here.
Function definition looks like this (I’m using serverless.js instead of .yml):
cognitoCustomMessageHandler: {
handler: 'handleUsers.cognitoCustomMessageHandler',
events: [{
cognitoUserPool: {
pool: '${self:provider.environment.COGNITO_POOL_NAME}',
trigger: 'CustomMessage',
existing: true,
}
},],
}
Deploying this once is successful and correctly attaches the lambda function to the pool trigger.
If the pool is subsequently updated or the handler is removed manually from the pool trigger using the Cognito User Pool console or otherwise, the function is no longer triggered (expected).
If the function is again deployed (whether or not using the --force
arg), the handler is no longer re-applied to the user pool trigger. Is this by design, or a bug? If by design, is there another way to force this to check for the proper setup?
Removing/commenting out the user pool trigger events from the handler, re-deploying, then adding them back in, and re-deploying again will force the link again, but I feel like there’s room for changes to be made and the trigger not to be reapplied correctly.