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.
To build this application run the following:
npm install -g aws-cdk
npm install
npm run build
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
The Lambda application code is under app/src
and contains:
app/src/createOrder
- used to store an order in the DynamoDB tableapp/src/getOneOrder
- used to get a single order from the DynamoDB tableapp/src/getAllOrders
- used to get all orders from the DynamoDB table
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
HTTP GET to {OrdersAPIEndpoint}/orders/{customerId}/{orderId}
Example:
curl -X GET https://XXXXXXXXX.execute-api.us-east-1.amazonaws.com/prod/orders/JoeUser1234/3
HTTP GET to {OrdersAPIEndpoint}/orders
Example:
curl -X GET https://XXXXXXXXX.execute-api.us-east-1.amazonaws.com/prod/orders/