Configuration Error in Serverless@2.19.0
Closed this issue · 4 comments
Plugin is throwing errors when trying to deploy.
Serverless Error ---------------------------------------
Configuration error at 'functions.connect.events[0]': unrecognized property 'caching'
Your Environment Information ---------------------------
Operating System: darwin
Node Version: 12.16.1
Framework Version: 2.19.0
Plugin Version: 4.4.2
SDK Version: 2.3.2
Components Version: 3.4.7
connect:
handler: connect/gateway/index.handler
description: Test API Connection
events:
- http: 'GET /test/connect'
caching:
enabled: true
ttlInSeconds: 3600
I found that it does work when the per-function level configuration is placed under custom
like this (instead of below each function as in my earlier comment).
custom:
apiGatewayCaching:
enabled: true
ttlInSeconds: 1
additionalEndpoints:
- method: GET
path: /test/connect
caching:
enabled: true
ttlInSeconds: 150
Hi @marc-parillo,
Thanks for raising the issue. My guess is that the apiGatewayCaching
configuration was missing in your first example.
This should work:
custom:
apiGatewayCaching:
enabled: true
functions:
connect:
handler: connect/gateway/index.handler
description: Test API Connection
events:
- http: 'GET /test/connect'
caching:
enabled: true
ttlInSeconds: 3600
The additionalEndpoints
feature is only recommended for when an endpoint is defined in CloudFormation, like in this example. The additionalEndpoints
section doesn't support things like cacheKeyParameters
.
Please let me know if you still have problems.
Thanks for merging my PR and your updated version 1.6.1!
I was testing out different configuration settings based on your suggestions and Serverless@2.19.0 still throws errors.
Example 1
custom:
apiGatewayCaching:
enabled: true
functions:
cached:
handler: cached/gateway/index.handler
description: Test API Caching
events:
- http: 'GET /cached'
caching:
enabled: true
ttlInSeconds: 30
Example 2
custom:
apiGatewayCaching:
enabled: true
functions:
cached:
handler: cached/gateway/index.handler
description: Test API Caching
events:
- http:
path: /cached
method: get
caching:
enabled: true
ttlInSeconds: 30
Same Error Both Times
Serverless Error ---------------------------------------
Configuration error at 'functions.cached.events[0]': unrecognized property 'caching'
At the top of my .yml
file, I do have a command to throw configuration errors
service: api-test
configValidationMode: error
So, I tried disabled configValidationMode: error
. Serverless stopped throwing theunrecognized property 'caching'
error. I checked API Gateway after deploying, the cache settings in my .yml
file did not propagate to API Gateway. In other words, caching for that particular endpoint was not enabled and the ttlInSeconds was not set to 30 as expected.
Closing this issue. It works fine. I didn't indent everything below http:
correctly.
events:
- http:
path: /cached
method: get
caching:
enabled: true
ttlInSeconds: 30