Skip to content

fargito/rust-cdk-serverless

Repository files navigation

Serverless CDK Rust

A sample serverless app with Rust. I'm just experimenting stuff here so don't take anything at face value 🙃.

Overview

A very simple todo API to create, retrieve and delete todos. No front for now.

This is the architecture schema:

Todo API schema

Setup

Requirements

NodeJS: See official NodeJS install docs. The current NodeJS version is stored in .nvmrc. If you use nvm, you can run:

nvm use

Pnpm: dependency manager. Install with:

npm install -g pnpm

Rust toolchain: for now the Rust version is not pinned. Follow the official install instructions.

Cargo Lambda: in order to cross-compile Rust code to Lambda runtime. Follow install instructions.

Installation

Install NodeJS dependencies:

pnpm install

AWS Setup

In order to deploy, you will need an AWS account. If you don't have one, refer to the AWS documentation.

Then install the AWS CLI: install docs.

Setup a local profile:

aws configure --profile <your-profile-name>

Build & Deploy

Build Rust Lambda code

pnpm build

Run tests

pnpm test

Deploy

⚠ Warning: you may have to log in to your AWS profile again, depending on the setup method.

pnpm run deploy --profile <your-profile-name>

Run integration tests

pnpm test-integration