我试图在我的SAM模板中设置我的lambda函数的事件,但我希望事件源是一个显式的API endpoints .
该文档显示了一个带有隐式API作为事件源的事件:
GetFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.get
Runtime: nodejs6.10
CodeUri: s3://bucket/api_backend.zip
Policies: AmazonDynamoDBReadOnlyAccess
Environment:
Variables:
TABLE_NAME: !Ref Table
Events:
GetResource:
Type: Api
Properties:
Path: /resource/{resourceId}
Method: get
这将是显式的API定义:
Resources:
MyApi:
Type: AWS::Serverless::Api
Properties:
StageName: prod
DefinitionUri: swagger.yml
如何将事件源明确设置为MyApi?
1 回答
我需要在事件定义下添加
RestApiId
,如下所示: