Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 341
Greg Pagendam-Turner Avatar asked Sep 26 '20 07:09

Greg Pagendam-Turner


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 
like image 59
MSOACC Avatar answered Sep 21 '22 08:09

MSOACC


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

- httpApi:     method: '*'     path: '*' 
like image 34
nekh Avatar answered Sep 20 '22 08:09

nekh