Skip to content

jmb12686/aws-dynamo-microservice

Repository files navigation

aws-dynamo-microservice

This is a simple demo microservice API utilizing AWS Lambda, API Gateway, and DynamoDB provisioned via AWS CDK. The application exposes a RESTful CRUD API backed by a DynamoDB table.

Build

To build this application run the following:

npm install -g aws-cdk
npm install
npm run build

Deploy

To deploy this application, use cdk and run the following commands:

cdk bootstrap; #only have to run once, no-op if ran again
cdk deploy

After CDK completes the deployment, the API's URL will be printed as output

Lambda application code

The Lambda application code is under app/src and contains:

  • app/src/createOrder - used to store an order in the DynamoDB table
  • app/src/getOneOrder - used to get a single order from the DynamoDB table
  • app/src/getAllOrders - used to get all orders from the DynamoDB table

API

Create an order

HTTP POST to {OrdersAPIEndpoint}/orders with customerId and orderId elements in the body as JSON. Example:

curl -X POST -d '{"customerId":"JoeUser1234", "orderId":"3", "amount":"12"}' https://XXXXXXXXX.execute-api.us-east-1.amazonaws.com/prod/orders

Get a single order

HTTP GET to {OrdersAPIEndpoint}/orders/{customerId}/{orderId} Example:

curl -X GET https://XXXXXXXXX.execute-api.us-east-1.amazonaws.com/prod/orders/JoeUser1234/3

Get all orders

HTTP GET to {OrdersAPIEndpoint}/orders Example:

curl -X GET https://XXXXXXXXX.execute-api.us-east-1.amazonaws.com/prod/orders/

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published