Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws-lambda-provided doesnt work #462

Closed
misogihagi opened this issue Apr 6, 2022 · 8 comments
Closed

aws-lambda-provided doesnt work #462

misogihagi opened this issue Apr 6, 2022 · 8 comments

Comments

@misogihagi
Copy link

related to #455

I used amazon/aws-lambda-provided:al2 instead lambci/lambda:provided
then
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"key":"hello"}'

responded nothing.

Deployed my function works well but offline docker version doesn't work.

how should I make it closer to running AWS lambda?

@calavera
Copy link
Contributor

calavera commented Apr 6, 2022

👋 hi @misogihagi we're going to need a little bit more information about your code. Do you get any compilation error?
Without more information, or a way to reproduce it, we cannot help you.

@misogihagi
Copy link
Author

misogihagi commented Apr 7, 2022

pulling my code,

git clone https://github.com/misogihagi/lambda-test.git
cd lambda-test

building,

sudo docker run --rm \
    -v ${PWD}:/code \
    -v ${HOME}/.cargo/registry:/root/.cargo/registry \
    -v ${HOME}/.cargo/git:/root/.cargo/git \
    rustserverless/lambda-rust

and running

sudo unzip -o \
    target/lambda/release/lambda-test.zip \
    -d /tmp/lambda && \
sudo  docker run \
    -p 9000:8080 \
    -v /tmp/lambda:/var/task \
    amazon/aws-lambda-provided:al2

then

curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"key":"hello"}' 

reproducing above.

@calavera
Copy link
Contributor

calavera commented Apr 7, 2022

@misogihagi I'm not familiar with that docker image, but for what you post, I think you need to modify the function path in the curl request with the name of your binary:

curl -XPOST "http://localhost:9000/2015-03-31/functions/YOUR-BINARY-NAME/invocations" -d '{"key":"hello"}' 

@seanpianka that's unrelated.

@misogihagi
Copy link
Author

It looks irrelevant...

curl -XPOST "http://localhost:9000/2015-03-31/functions/lambda-test/invocations" -d '{"key":"hello"}' 

returned
404 page not found

how can I test offline...

@calavera
Copy link
Contributor

My recommendation is to use cargo-lambda. You don't need docker, and I know it works, because I wrote it, and I just tested it with your repository 🤣

This is how you use it for you test repository:

1: Install

cargo install cargo-lambda

2: In the root of your repository, start the server in one terminal with:

cargo lambda watch

3: Send invoke requests from another terminal:

cargo lambda invoke --data-ascii '{"firstName": "David"}'

@bnusunny
Copy link
Contributor

bnusunny commented Apr 11, 2022

@misogihagi You should mount the custom runtime bootstrap under /var/runtime directory inside the container.

sudo  docker run \
    -p 9000:8080 \
    -v /tmp/lambda:/var/runtime \
    amazon/aws-lambda-provided:al2

@misogihagi
Copy link
Author

@calavera
thanks to advice!
cargo-lambda cannot be installed though..

error: `MaybeUninit::<T>::assume_init` is not yet stable as a const fn
   --> /home/user/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/kstring-2.0.0/src/string.rs:844:17
    |
844 |                 std::mem::MaybeUninit::uninit().assume_init()
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: could not compile `kstring` due to previous error
warning: build failed, waiting for other jobs to finish...
error: failed to compile `cargo-lambda v0.6.0`, intermediate artifacts can be found at `/tmp/cargo-installRi8vo2`

Caused by:
  build failed

@bnusunny
Yes!
what you said hit a bullseye!
Thanks!

@davidbarsky
Copy link
Contributor

@misogihagi assume_init was made const in 1.59 (https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.assume_init). While that version of Rust was released 7 weeks ago, I suggest updating every 6 weeks if you can—the current stable version of Rust is 1.60.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants