Carova

Serverless AWS Lambda Function as API Gateway Endpoint

Serverless template to create an AWS Lambda Function connected to an existing API Gateway API. The API Endpoint has an example of a dynamic path variable and allowed querystrings.

Add the following YAML to the provider and functions sections of your Serverless file.

1provider: 2 apiGateway: 3 restApiId: ${ApiGatewayID} 4 restApiRootResourceId: ${ApiGatewayRootResourceID} 5 6functions: 7 ApiListMethod: 8 handler: src/api/index.queryhandler 9 events: 10 - http: 11 path: /animals/{primaryKey} 12 method: get 13 request: 14 parameters: 15 paths: 16 primaryKey: true 17 querystrings: 18 secondaryKey: false 19 iamRoleStatements: 20 - Effect: Allow 21 Action: 22 - dynamodb:* 23 Resource: 24 - '*' 25 iamRoleStatementsInherit: true 26 timeout: 30