Configure Authenticator for REST API

I am trying to configure an authorizer for my REST API but something just isn’t right. I followed the instructions of a SO post that instructed to do it like so:

functions:
  RequestUnicorn:
      handler: src/backend/requestUnicorn.handler
      events:
       - http:
            path: /rides  
            method: post    
            cors: true
            integration: lambda
            authorizer:
              name: wildrydez
              arn: arn:aws:cognito-idp:eu-central-1:183224933160:userpool/eu-central-1_HkrGy1GOi

I double-checked the arn of the pool after I deployed the app though no Authorizer is visible in the API Gateway
image

During my research I stumbled upon Fernandos article about Authorizers for HTTP APIs. Following his instructions I got the example working but I can’t map it to my use case, as I need a REST API.

Has anyone achieved this with serverless 1.70?

  Your Environment Information ---------------------------
     Operating System:          win32
     Node Version:              12.16.1
     Framework Version:         1.70.1 (standalone)
     Plugin Version:            3.6.11
     SDK Version:               2.3.0
     Components Version:        2.30.10

Update:

I used Dehli’s answer in the same SO post that I referenced in my initial question:

functions:
  functionName:
# ...
events:
  - http:
      # ...
      authorizer: 
         type: COGNITO_USER_POOLS
         authorizerId: 
           Ref: ApiGatewayAuthorizer

resources:
  Resources:
    ApiGatewayAuthorizer: 
      Type: AWS::ApiGateway::Authorizer
      Properties: 
        Name: CognitoUserPool
        Type: COGNITO_USER_POOLS
        IdentitySource: method.request.header.Authorization
        RestApiId: 
          Ref: ApiGatewayRestApi
        ProviderARNs: 
          - Fn::GetAtt:
              - UserPool
              - Arn

    UserPool:
      Type: AWS::Cognito::UserPool
1 Like