REST Product microservice application written in Go using DynamoDB and Amazon Lambda.
- Node.js & NPM
- Serverless framework:
npm install -g serverless
- Go
- dep:
brew install dep && brew upgrade dep
- Clone the repo
git clone git@github.com:miamiruby/serverless-go-dynamodb-lambda-microservice.git
cd serverless-go-dynamodb-lambda-microservice
- Install Go dependencies
dep ensure
- Compile functions as individual binaries for deployment package:
./scripts/build.sh
You need to perform this compilation step before deploying.
- Deploy!
serverless deploy
You can perform steps 2 and 3 simultaneously by running
./scripts/deploy.sh
.
- To Create a Record:
Use curl to create product:
> curl -X POST -H "Content-Type:application/json" https://<hash>.execute-api.<region>.amazonaws.com/dev/products --data '{
"title": "The Hitchhikers Guide to the Galaxy",
"description": "42",
"done": false,
"price": 10.00,
"created_at": "2018-01-23 08:48:21.211887436 +0000 UTC m=+0.045616262"
}'
- List All Records:
Use curl to list products:
> curl https://<hash>.execute-api.<region>.amazonaws.com/dev/products
{
"products": [
{
"id": "d2e38e20-2e73-1e24-9390-1747cf5d19b5i",
"title": "The Hitchhikers Guide to the Galaxy",
"description": "42",
"done": false,
"price": 1.00,
"created_at": "2018-01-23 08:48:21.211887436 +0000 UTC m=+0.045616262"
}
]
}
- Delete Record:
Use curl to delete a product:
> curl -X DELETE https://<hash>.execute-api.<region>.amazonaws.com/dev/products/d2e38e20-2e73-1e24-9390-1747cf5d19b5i