This repository contains a RESTful API implemented in Rust, which performs Create and Read operations for a "Course" entity. Each Course has three attributes:
course_id
course_name
course_category
-
Write/Edit Rust code in the src/bin folder
-
Format the Rust code using :
cargo fmt
-
Compile binaries of the Rust Code :
cargo lambda build --release
The infrastructure is provisioned using AWS CDK.
To deploy the API, follow these steps:
- Navigate to the
deploy
directory:cd deploy
- Install the required dependencies:
npm install
- Generate the CloudFormation template using CDK:
cdk synth
- Deploy the infrastructure using CDK:
cdk deploy
This will create the necessary AWS resources, including:
- Three Lambdas:
getById
,getByCategory
, andcreate
, each with its own Function URL. - One DynamoDB table:
CourseTable
. - One API Gateway with three endpoints:
/get
,/getByCategory
, and/create
.
The Lambdas are implemented using three separate Rust handlers, each compiled into a binary.
Before developing/deploying the API, make sure you have the following prerequisites:
- Rust compiler installed on your system.
- AWS CDK installed.
- Cargo Lambda installed.
Here are some references that I found helpful and also want to give credit to:
- https://dynobase.dev/dynamodb-aws-cdk/
- https://github.com/Durgaprasad-Budhwani/rust-based-aws-lambda-example
- https://www.youtube.com/watch?v=uhE3Z2lGGXQ
- https://www.udemy.com/course/aws-lambda-serverless/
- https://bobbyhadz.com/blog/aws-cdk-api-gateway-example
- https://www.youtube.com/watch?v=T-H4nJQyMig