A simple example using ApiGateway or ApiGateway + Lambda to interact with Dynamo DB, using:
- TypeScript + Node for lambda implementation
- API Gateway + OpenAPI/Swagger integration for API validation
- AWS SAM for infrastructure templating
- Node + NPM
- aws-cli (installed and configured)
- aws-sam-cli
There's a sh file called deploy.sh
meant to be used for infrastructure creating/updating:
sh deploy.sh <STACK_NAME> <S3_BUCKET>
Where:
STACK_NAME
is the name of the stackS3_BUCKET
refers to an existing S3 bucket where the OpenAPI definition is going to be upload
An API whose Url can be obtained on the CloudFormation stack outputs (ApiUrl
) with the endpoints:
- Directly from API Gateway using DynamoDB API:
GET /owner/all
: scansOwner
table.GET /owner
: queriesOwner
table.POST /owner
: puts an item toOwner
table.GET /owner/{ownerId}
: gets an owner item by its Id fromOwner
table.PUT /owner/{ownerId}
: updates an item by its Id toOwner
table.DELETE /owner/{ownerId}
: deletes an item by its Id toOwner
table.
- API Gateway AWS integration to Lambda Function, and using the
aws-sdk
to interact with DynamoDBGET /pet/all
: scansPet
table.GET /owner/{ownerId}/pet
: queriesPet
table filtering by an owner.POST /owner/{ownerId}/pet
: puts an item toPet
table associated to a particular owner.GET /owner/{ownerId}/pet/{petId}
: gets an item by its Id fromPet
table.PUT /owner/{ownerId}/pet/{petId}
: updates an item by its Id toPet
table.DELETE /owner/{ownerId}/pet/{petId}
: deletes an item by its Id toPet
table.