aws-lambda-cpp icon indicating copy to clipboard operation
aws-lambda-cpp copied to clipboard

Documentation on how to run locally is lacking

Open mtfurlan opened this issue 7 months ago • 0 comments

I would like to test a lambda locally, without deploying anything to aws which it seems like SAM needs?

The readme says to use amazonlinux:2017.03, but I only got it working with public.ecr.aws/lambda/provided:al2

Steps:

git clone https://github.com/awslabs/aws-lambda-cpp
cd aws-lambda-cpp

cmake -B build . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install
cmake --build build -t install

CMAKE_PREFIX_PATH=install/lib/aws-lambda-runtime/ cmake -B build-sample examples/demo/
cmake --build build-sample/ -t aws-lambda-package-demo

unzip -d zip build-sample/demo.zip
docker run -v $(pwd)/zip:/var/task:ro -v $(pwd)/zip:/var/runtime:ro -p 9000:8080 public.ecr.aws/lambda/provided:al2 demo
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"payload":"hello world!"}'

I feel like this is not exactly correct, but it's at least closer than anything else I've found on the internet. If someone else can make a PR that explains this better that would be best, but if someone can just explain how to improve what I did I can make the PR

mtfurlan avatar May 15 '25 18:05 mtfurlan