我正在尝试将现有的Spring Boot应用程序转换为AWS Lambda,并使用SAM。
我试图使用aws-sam-cli在本地测试我的Lambda,但是在我的SAM设置中,我收到以下错误:Template does not have any APIs connected to Lambda functions
当我运行sam local start-api
时,出现这个问题。
我的template.yml
文件:
AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: foo
Resources:
MailFunction:
Type: AWS::Serverless::Function
Properties:
Handler: bar.LambdaHandler::handleRequest
Runtime: java8
CodeUri: target/foo-bar-1.0.jar
Timeout: 300
MemorySize: 1024
Events:
Timer:
Type: Schedule
Properties:
Schedule: rate(1 day)
我错在哪里了?就我所知道的,这看起来是正确的。参考 https://blog.couchbase.com/aws-serverless-lambda-scheduled-events-tweets-couchbase/ 和 https://docs.aws.amazon.com/lambda/latest/dg/tutorial-scheduled-events-schedule-expressions.html
sam local
,你需要使用generate-event
。请查看我的更新答案。 - H6.sam local invoke function-name -e event_file.json
。 - H6.