【发布时间】:2021-11-08 22:37:08
【问题描述】:
我尝试从serverless 部署类似this example 的东西。构建我的serverless.yml,我遇到了这个错误,我找不到处理的句柄:
service: products-api
package:
artifact: target\products-api-dev.jar
#artifact: target\${self:service}-${self:provider.stage}.jar #cool alternative :)
provider:
name: aws
runtime: java8
#Copy-pasted
resources:
Resources:
productsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: products_table
AttributeDefinitions:
- AttributeName: id
AttributeType: S
- AttributeName: name
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
- AttributeName: name
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
functions:
listProducts:
handler: com.serverless.ListProductsHandler
events:
- http:
path: /products
method: get
getProduct:
handler: com.serverless.GetProductHandler
events:
- http:
path: /products/{id}
method: get
createProduct:
handler: com.serverless.CreateProductHandler
events:
- http:
path: /products
method: post
deleteProduct:
handler: com.serverless.DeleteProductHandler
events:
- http:
path: /products/{id}
我得到的错误是——在我自己的代码中没有对错误的引用很难发现我出错的地方。 我查看了许多 Q/A,包括 this 和 this,但那里似乎更多的是 javascript 和打字稿问题,而不是这里的无服务器。
Type Error ----------------------------------------------
TypeError: Cannot read property 'toLowerCase' of undefined
at AwsCompileApigEvents.getHttpMethod (C:\snapshot\serverless\lib\plugins\aws\package\compile\events\apiGateway\lib\validate.js:195:24)
at C:\snapshot\serverless\lib\plugins\aws\package\compile\events\apiGateway\lib\validate.js:50:30
at Array.forEach (<anonymous>)
at C:\snapshot\serverless\lib\plugins\aws\package\compile\events\apiGateway\lib\validate.js:45:37
at Array.forEach (<anonymous>)
at AwsCompileApigEvents.validate (C:\snapshot\serverless\lib\plugins\aws\package\compile\events\apiGateway\lib\validate.js:44:55)
at Object.package:compileEvents [as hook] (C:\snapshot\serverless\lib\plugins\aws\package\compile\events\apiGateway\index.js:318:31)
at PluginManager.invoke (C:\snapshot\serverless\lib\classes\PluginManager.js:579:20)
at async PluginManager.spawn (C:\snapshot\serverless\lib\classes\PluginManager.js:601:5)
at async Object.before:deploy:deploy [as hook] (C:\snapshot\serverless\lib\plugins\deploy.js:60:11)
at async PluginManager.invoke (C:\snapshot\serverless\lib\classes\PluginManager.js:579:9)
at async PluginManager.run (C:\snapshot\serverless\lib\classes\PluginManager.js:639:7)
at async Serverless.run (C:\snapshot\serverless\lib\Serverless.js:452:5)
at async C:\snapshot\serverless\scripts\serverless.js:751:9
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
【问题讨论】:
标签: aws-lambda serverless-framework serverless aws-serverless aws-java-sdk