我有一个可生成API的cloudformation模板。我希望端点之一具有路径参数。但是,我不明白如何使用AWS::Serverless::Function
实现此目标。这是我当前的功能:
GetItems:
Type: AWS::Serverless::Function
Properties:
Handler: api/items/get.handler
Timeout: 29
CodeUri: .
Events:
Get:
Type: Api
Properties:
Method: get
Path: /items
RestApiId: !Ref MyAPI
这将创建一个类似于aws-domain-example.com/v1/items
的端点。这样就可以了。
但是,我要aws-domain-example.com/v1/items/{item_id}
如何添加路径参数?
我相信模板应如下所示。因此您可以通过event.pathParameters.itemCode
Events:
Get:
Type: Api
Properties:
Path: /item/{itemCode}
Method: get