I have a cloudformation template that generates an API. I want one of the endpoints to have a path parameter. However, I don't understand how I can achieve this with AWS::Serverless::Function. Here is my current 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
This creates an endpoint like aws-domain-example.com/v1/items. This works just fine.
However, I want aws-domain-example.com/v1/items/{item_id}
How can I add a path parameter?
I believe template should be as below. so you can access it as event.pathParameters.itemCode
Events:
Get:
Type: Api
Properties:
Path: /item/{itemCode}
Method: get
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With