How to configure multiple Cognito triggers in Serverless framework?

Viewed 982

I'm trying to create multiple Cognito triggers to the same user-pool in the Serverless framework, but for some reason, I can't get it to work!!

my functions config is as the following

functions:
  PreSignUp:
    handler: dist/cognito-pre-signup.preSignUp
    events:
      - cognitoUserPool:
          pool: app-user-pool
          trigger: PreSignUp
          existing: true
  PostConfirmation:
    handler: dist/cognito-post-confirmation.postConfirmation
    events:
      - cognitoUserPool:
          pool: app-user-pool
          trigger: PostConfirmation
          existing: true

the thing is when I try to sign-up I get an error says that "PostConfirmation invocation failed due to error AccessDeniedException."

but the really weird thing is that if I swap the positions of the functions in the config file, say for example

functions:
  PostConfirmation:
    handler: dist/cognito-post-confirmation.postConfirmation
    events:
      - cognitoUserPool:
          pool: app-user-pool
          trigger: PostConfirmation
          existing: true
  PreSignUp:
    handler: dist/cognito-pre-signup.preSignUp
    events:
      - cognitoUserPool:
          pool: app-user-pool
          trigger: PreSignUp
          existing: true

then the error message becomes "PreSignUp invocation failed due to error AccessDeniedException.", which means that the error has something to do (related somehow) with the order of the functions config, so, the function that comes first at the config file works just fine but the other one ends up with "AccessDenied" error.

1 Answers

Okay, in case someone else faced the same issue, this SO answer helped me.

Related