How to define Cognito UserMigration trigger?

I’m trying to set a UserMigration trigger for Cognito. The PR https://github.com/serverless/serverless/pull/6511 says how to configure it, but I just cannot get it to work. Although the Cognito UserPool is created and the Lambda function is uploaded, the trigger is not connected to Cognito.

Here is my function declaration:

functions:
  migrateUsers:
    handler: functions/users.migrate
    name: migrateUsers-${self:custom.myStage}
    description: Migrates Gixtra users to Cognito upon signup/signin
    events:
      - cognitoUserPool:
        pool: MyUserPool
        trigger: UserMigration
        existing: true

And here is the UserPool:

resources:
  Resources:
    CognitoUserPoolMyUserPool:
    Type: AWS::Cognito::UserPool
    Properties:
      UserPoolName: ${self:custom.userPoolName}
      UsernameAttributes:
        - email
      AutoVerifiedAttributes:
        - email

I have tried to reference the UserPool in the “trigger” as MyUserPool, CognitoUserPoolMyUserPool and cognitoUserPoolMyUserPool. Whatever I try, the trigger is never set.

Any hints at what I do wrong are appreciated.