#aws #lambda #docker #build #ec2


Build Rust crates for deployment to AWS EC2 or AWS Lambda

5 releases

0.10.0 Nov 18, 2021
0.9.3 Dec 5, 2020
0.9.2 Oct 17, 2020
0.9.1 Sep 12, 2020
0.9.0 Sep 12, 2020

#9 in #ec2

36 downloads per month
Used in aws-build


377 lines


crates.io Documentation

Build a Rust project in a container for deployment to either an instance running AWS Linux 2 or AWS Lambda.

Both a library and an executable are provided. The executable is a very thin wrapper around the library.

This crate only handles building the project locally. It does not interact with any AWS services.


Install with:

cargo install aws-build

In the common case you should be able to just run aws-build al2 or aws-build lambda in the directory of the project you want to build.

On successful completion, the output file (either a standalone executable for Amazon Linux 2 or a zip file containing a "bootstrap" executable for AWS Lambda) is written to a subdirectory of the target directory. There is also a target/latest-al2 or target/latest-lambda symlink that points to the output file.

aws-build <mode> [<project>] [--container-cmd <container-cmd>] [--rust-version <rust-version>] [--strip] [--bin <bin>] [--package <package...>] [--code-root <code-root>]

Build the project in a container for deployment to AWS.

mode: al2 or lambda (for Amazon Linux 2 or AWS Lambda, respectively)
project: path of the project to build (default: current directory)

  --container-cmd   base container command, e.g. docker or podman, auto-detected
                    by default
  --rust-version    rust version (default: latest stable)
  --strip           strip debug symbols
  --bin             name of the binary target to build (required if there is
                    more than one binary target)
  --package         yum devel package to install in build container
  --code-root       root directory to mount into the container, must contain the
                    project path (default: project path)
  --help            display usage information
  • amazon-linux: Docker image replicating the Aamazon Linux environment.
  • cargo-aws-lambda: "dependency free cargo subcommand for cross-compiling, packaging and deploying code quickly to AWS Lambda"
  • docker-lambda: "A sandboxed local environment that replicates the live AWS Lambda environment almost identically"
  • lambda-rust: "a faithful reproduction of the actual AWS [...] Lambda runtime environment" with the stable Rust toolchain installed


~163K SLoC