Auction Service CRUD Operations
Middleware
Middleware are functions that run either before or after your Lambda handler
.
We will be using middy
, a middleware engine for AWS Lambda.
Common middlewares
GET Request: Scanning
If you recall, scanning get items by looking through an entire table, which is inefficient. But it's good to know how to do it using the AWS SDK.
Note: If you're adding a new GET endpoint using scan
, you'll need to update the Serverless framework in a few places:
Add a lambda function for the endpoint
Include the operation type
dynamodb:Scan
in the IAM config
GET Request: Querying by Key
Querying is more efficient as it can make use of primary partition keys when looking for items.
Similarly, you want to update the serverless.yml
:
Include a lambda function for the new endpoint
Include operation type
dynamodb:GetItem
in the IAM config
PATCH Request: Updating
To update an item, you query by key and provide the properties you want to change. Here's the rough syntax:
Last updated