An example REST Rust web service, with a DynamoDB backend.
This project uses the rocket.rs web framework to define an API for creating, reading, updating, deleting and listing products.
It uses Rusoto and Dynomite for accessing Amazon DynamoDB.
This repository currently uses the master
branch of Rocket, due to support for async/tokio.
If you're interested in what this would look like with Serverless and AWS Lambda (instead of Rocket), then check out this cool repo that my collegue Nicolas Moutschen put together:
https://github.com/nmoutschen/rust-rest-serverless
First install the Rust toolchain, by following the instructions at: https://rustup.rs/
Then clone the repo:
$ git clone https://github.com/PaulMaddox/rust-rest-dynamodb.git
$ cd rust-rest-dynamodb
You will need to make sure that:
- You have valid AWS credentials (either env variables, IAM role or ~/.aws/credentials file)
- You create a DynamoDB table in advance, called
products
. It only needs a single field defined (the partition key) calledid
, of type String. - The region in main.rs matches the region you have the DynamoDB table deployed to
... and finally run the project with cargo
$ cargo run