因此,我尝试将现有的 Spring Boot 应用程序转换为 AWS lambda 并使用 SAM。
我正在尝试使用 aws-sam-cli 在本地尝试我的 lambda,但是通过我的 SAM 设置,我得到:Template does not have any APIs connected to Lambda functions
当我做:sam local start-api
My 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://blog.couchbase.com/aws-serverless-lambda-scheduled-events-tweets-couchbase/ + https://docs.aws.amazon.com/lambda/latest/dg/tutorial-scheduled-events-schedule-expressions.html https://docs.aws.amazon.com/lambda/latest/dg/tutorial-scheduled-events-schedule-expressions.html
您没有向函数添加任何 API Gateway 事件。和start-api
生成本地 API 网关。
您需要至少添加一项Api
事件给你的Events
部分。
Events:
[...]
Api:
Type: Api
Properties:
Path: /myresource
Method: get
如果你只有一个Schedule
事件,尝试使用generate-event
创建这样一个事件。
sam local generate-event schedule ...
并调用函数,例如sam local invoke function-name -e event_file.json
(see https://docs.aws.amazon.com/lambda/latest/dg/test-sam-cli.html)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)