This repository contains an architecture of an AWS Lambda Rust Application. This couldn't have been possible without the great article from SilentByte.
To-do soon : Putting a good structure of tests
This application is composed of four crates (subprojects) :
lambda_dispatcher
: contains the necessary interface for working with AWS Lambdaspotipal_api
: contains the DTO objects used for requests and responsesspotipal_business
: this contains the main business logic of the applicationwebserver
: a webserver wrapper permitting you to launch your app locally, mainly for dev purposes but you could use it to deploy your app in production without the using of the lambdas
You will need Rust Nightly toolchain installed on your computer
You can launch your webserver localy thanks to the webserver included, with the following command :
cargo run --bin webserver
This should launch your webserver. You should make a POST request at http://localhost:3000/hello-world
with the following content :
{
"name": "Dimitri"
}
And you will have a nice hello world message with your name on it !
You will need Serverless installed on your computer, and Docker installed, and running
You will probably want to test your lambda before deploying it. Serverless allows local invocation of the lambda, using the following request :
serverless invoke local -f hello-world -d '{"body": "{\"name\":\"Dimitri\"}"}'
And the emulated lambda will answer you ! Victory !
For this, you will need to configure your serverless account, login with it, and connect it to your aws account.
Once it's done, you will just have to do this :
serverless deploy
And your lambda should be uploaded and running in seconds !