This is a simple REST API application that handles requests to insert and query a DynamoDB table. It uses a CDK Stack to deploy the API Gateway with the required routes, a Lambda function using Node runtime, and the DynamoDB table.
The requirements for the schema are defined and enforced at the API Gateway level, on lib/cdk1-stack.ts
- AWS CDK environment configured and initialized with required credentials
- AWSCloudFormationFullAccess role attached to corresponding user
cdk deploy
It returns the API URL
The REST API examples are below:
Creates a new product by passing the required parameters in compliance with the validation schema.
POST /products
curl --location --request POST 'API_URL/products' \--header 'Content-Type: application/json' \--data-raw '{"name": "foo","id": "2","price": 5,"tags":["tag1","tag2","tag3"]}'
Retrieves a product by passing it's productId.
GET /products
curl --location --request GET 'API_URL/products?productId=123' --data-raw ''
Retrieves all products containing matching tags.
POST /search
curl --location --request POST 'API_URL/search?tags=mango' \--data-raw ''