Skip to content

Documentation on how to run locally is lacking #207

Open
@mtfurlan

Description

@mtfurlan

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions