Skip to content

Instantly share code, notes, and snippets.

@ceejbot
Last active September 1, 2021 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ceejbot/748cc7aaac61f5b31594c0642cadd625 to your computer and use it in GitHub Desktop.
Save ceejbot/748cc7aaac61f5b31594c0642cadd625 to your computer and use it in GitHub Desktop.
fast notes on how to build and test rust lambdas in local dev on a mac
# this goes into your ~/.cargo/config file
[target.x86_64-unknown-linux-musl]
linker = "x86_64-linux-musl-gcc"
#!/bin/bash
# install the musl-cross build environment
brew install filosottile/musl-cross/musl-cross
# symlink
ln -s /usr/local/bin/x86_64-linux-musl-gcc /usr/local/bin/musl-gcc
# install the target toolchain
rustup target add x86_64-unknown-linux-musl
# build the lambda
cargo build --target x86_64-unknown-linux-musl
# start a docker container replicating the "provided" lambda runtime
# put your lambda into `bootstrap`
mkdir -p /tmp/lambda && \
cp target/x86_64-unknown-linux-musl/debug/your-lambda /tmp/lambda/bootstrap && \
docker run -i -e DOCKER_LAMBDA_USE_STDIN=1 \
--rm \
-v /tmp/lambda:/var/task \
lambci/lambda:provided
# send your json blob input to STDIN somehow (paste or script output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment