rust-rest-dynamodb icon indicating copy to clipboard operation
rust-rest-dynamodb copied to clipboard

A simple REST Rust web service, with a DynamoDB backend

rust-rest-dynamodb

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.

Alternative: Deploy using AWS Lambda

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

Running this example

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) called id, 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