Event integration type http requires handler?

There appears to be a problem with the newly added http integration type.
Trying to define one, as a proxy to CloudSearch and it complains that I didn’t define a handler.

edit: removing a lot of my experimentation that’s unrelated to the stated question. will post a separate topic regarding querystring passthrough.

Here’s the relevant serverless.yml

  search:
    events:
      - http:
          path: /restapi/v1/search
          method: get
          cors: true
          authorizer:
            arn: "arn:aws:cognito-idp:${self:custom.currentRegion}:############:userpool/${self:custom.userPoolId}"
          integration: http
          request:
            uri: "https://<cloudsearch-url-stuff>.<region>.cloudsearch.amazonaws.com/2013-01-01/search"
            parameters:
              'method.request.querystring.fq': false
              'method.request.querystring.pretty': false
              'method.request.querystring.q': true
              'method.request.querystring.q.cursor': false
              'method.request.querystring.q.options': false
              'method.request.querystring.q.parser': false
              'method.request.querystring.return': false
              'method.request.querystring.size': false
              'method.request.querystring.sort': false
              'method.request.querystring.start': false
          response:
            statusCodes:
              200:
                pattern: ''

Issuing sls deploy -s brett results in the following error:

  Serverless Error ---------------------------------------

     Missing "handler" property in function ""search". Please
     make sure you point to the correct lambda handler. For
     example: handler.hello. Please check the docs for more
     info

  Stack Trace --------------------------------------------

I assume this is a bug as there shouldn’t be a Lambda function required in the resulting stack.
I’ve implemented it through the AWS Console and had it working. I’m just trying to include it in my serverless.yml so it stays in sync with the rest of my stack and can be deployed to other stages/environments without manual intervention.

Including a dummy handler removes the error, but creates a Lambda function that’s just taking up space not being used…

Is this a bug?

Unfortunately setting up a dummy handler is the only way to get it working currently. As they say, it’s not a bug, it’s a feature :wink:. This is because events are tied to functions i.e. you cannot define events without a corresponding Lambda.

After v1.14 releases, the docs will have more information but tl;dr is there will be more integration types (HTTP_PROXY, MOCK).

1 Like

Thanks for the response @hassankhan.
That makes sense. And it’s what I assumed. I just wanted to make sure I wasn’t missing something obvious.

What does twos dummy handler look like?

I’m getting this same error message. :slight_smile:

Thanks in advance!

The added handler definition in serverless/yml

  search:
    handler: applications/dummy.handler
    events:
      - http:
...

The dummy.handler code:

'use strict'

const success = require('../libs/response-lib').success

module.exports.handler = (event, context, callback) => {
  console.log('Dummy')
  callback(null, success({'message': 'dummy'}))
}

Hey thank you @bfieber . I’ll try that.

I got it working with some slightly different sample code out of GitHub:

-Sean