This is a backend for a trivial web application: the idea is for users to add their daily steps, which is aggregated towards the goal of walking around the world.
This served as a nice first project for working with Rust and serverless infrastructure.
- 🦀 Rust 🙏
- 🔓 Cognito for login and identity management
- 🚀 API Gateway REST API (with request body validation to prevent failed lambda invocations)
- 🧨 DynamoDb
- 🛠 Staged deployments for everything!
Install the serverless framework cli.
Run npm ci
, which will make sure npm dependencies are installed based directly on your package-lock.json file. This only needs run once.
The first time you run npx serverless deploy
it will pull down and compile the base set
of dependencies and your application. Unless the dependencies change afterwards,
this should only happen once, resulting in an out of the box rapid deployment
cycle.
TODO using Github actions
serverless deploy -v
The -v
is important as this will print out all the created resources from cloudformation. These resources are then environment variables for the frontend.
Either use a real signup flow or create a user using the aws cli
aws cognito-idp sign-up \
--region YOUR_COGNITO_REGION \
--client-id YOUR_COGNITO_APP_CLIENT_ID \
--username admin@example.com \
--password Passw0rd!
And then verify the user
aws cognito-idp admin-confirm-sign-up \
--region YOUR_COGNITO_REGION \
--user-pool-id YOUR_COGNITO_USER_POOL_ID \
--username admin@example.com
With your function deployed you can now tail it's logs right from your project
$ npx serverless logs -f $FUNCTION_NAME
Good code should be easily replaceable. Good code is should also be easily disposable. Retiring applications should be as easy as creating and deploying them them. The dual of serverless deploy
is serverless remove
. Use this for retiring services and cleaning up resources.
$ npx serverless remove
This was bootstrapped from this Rust serverless template.
-
See the serverless-rust plugin's documentation for more information on plugin usage.
-
See the aws rust runtime's documentation for more information on writing Rustlang lambda functions
-
Much of this infra was inspired by serverless-stack