Creating an authorizer for a lambda

I’d like to script what I do by hand in the AWS console:

Capture

I tried with

functions:
  my-backend:
    handler: com.my.backend.LambdaHandler
    events:
      - http:
          path: /{proxy}
          method: any
          authorizer:
            type: COGNITO_USER_POOLS
            name: my-auth
            id: xxxxxx
            identitySource: method.request.header.Authorization
      - cognitoUserPool:
          pool: eu-west-1_xxxxx

serverless deploy return Function "my-auth" doesn't exist in this Service although I created it by hand and tested it.

Is it possible to have it created automatically?

EDIT:

I managed to get rid of the “function not found” error by using the arn of my cognito pool to the authorizer

Now I get a request timeout while testing the lambda.

When you say “created it by hand” do you mean outside of serverless? my-auth needs to be a function defined in your serverless.yml file.

Also, it’s very unlikely that you have a Lambda that responds to both http and cognitoUserPool events so I suspect that’s been configured incorrectly.