This projects uses an APIGateway with CORS enabled, pointing to five Lambdas executing CRUD operations on a single DynamoDB table.
To build this app, you need to be in this example's root folder. Then run the following:
npm install -g aws-cdk
npm install
npm run build
This will install the necessary CDK, then this example's dependencies, then the lambda functions' dependencies, and then build your TypeScript files and your CloudFormation template.
Run cdk deploy
. This will deploy / redeploy your Stack to your AWS Account.
After the deployment you will see the API's URL, which represents the url you can then use.
The whole component contains:
- An API, with CORS enabled on all HTTTP Methods. (Use with caution, for production apps you will want to enable only a certain domain origin to be able to query your API.)
- Lambda pointing to
src/create_book.py
, containing code for storing a book into the DynamoDB table. - Lambda pointing to
src/delete_book.py
, containing code for deleting books from the DynamoDB table. - Lambda pointing to
src/get_books.py
, containing code for getting all books from the DynamoDB table. - Lambda pointing to
src/get_book.py
, containing code for getting a book from the DynamoDB table. - Lambda pointing to
src/update_book.py
, containing code for updating a book in the DynamoDB table. - A DynamoDB table
books
that stores the data. - Five
LambdaIntegrations
that connect these Lambdas to the API.
- The Countries and Languages properties cannot have values stored in an array.
- REST API is not documented in API Gateway.
- No tests are written.
npm run build
compile typescript to jsnpm run watch
watch for changes and compilenpm run test
perform the jest unit testscdk deploy
deploy this stack to your default AWS account/regioncdk diff
compare deployed stack with current statecdk synth
emits the synthesized CloudFormation template