Serverless Configuration warning at 'functions.app.events[0]': unsupported function event

Viewed 16414

I'm trying to deploy an AWS API with serverless.com

When I do:

sls --stage=dev --aws-profile=myprofile deploy --force

I get the following warning:

Configuration warning at 'functions.app.events[0]': unsupported function event

My serverless.yml contains the section:

functions:
  app:
    handler: src/index.handler
    memorySize: 3008
    events:
      - httpApi:
        method: '*'
        path: '*'
        authorizer:
          name: serviceAuthorizer
          scopes: # Optional
            - user.id
            - user.email

What is wrong with the events section?

2 Answers

The issue is indeed indentation. The indentation on this is weird so I will explain it below. Every · is a space:

functions:
··hello:
····handler: handler.hello
····events:
······- http:
··········path: /hello
··········method: get

Some pointers:

  • There is a space after the - http: hyphen.
  • The next line is indented oddly - this is what's causing the issue. Rather than just two spaces of indent after defining our event type (http in my case), there are actually 4. I don't know why but that's what it demands.

Another tip: if you find your text editor is auto-formatting your YAML file and replacing the space indentation with tabs or whatever, add a .editorconfig file to the root with these settings:

[*.yml]
indent_size = 2
indent_style = spaces

I had a similar issue. The problem was with indentation. Try to fix it like this:

- httpApi:
    method: '*'
    path: '*'
Related