hanabu / lambda-web

Run Rust web frameworks on AWS Lambda
MIT License
115 stars 38 forks source link

Invalid entrypoint on AWS Lambda #14

Open marcustut opened 1 year ago

marcustut commented 1 year ago

Couldn't find valid bootstrap(s): [/var/task/bootstrap /opt/bootstrap] Runtime.InvalidEntrypoint

I'm having this issue after uploading the .zip file that was successfully built by CodeBuild. FYI, I'm using a subdirectory to house my code. So, in CodeBuild I configured the path to be trading-api/buildspec.yml. And in the yml file I have to make few changes so that the build pass.

Following lines with <-- shows the changed lines

version: 0.2

env:
  variables:
     PATH: "/root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/codebuild/user/bin"
phases:
  install:
    commands:
      # Install rust toolchanin
      - curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
  build:
    commands:
      # move into code directory
      - cd trading-api # <---
      # build Rust binary
      - cargo build --release
      # binary name must be "bootstrap" for Lambda custom runtime
      - mv target/release/trading-api bootstrap
      # strip & check size, dependencies
      - strip --strip-all bootstrap
      - size bootstrap
      - ldd bootstrap
artifacts:
  files:
    - trading-api/bootstrap # <---
    # - add other resources such as CSS, Javascript assets, etc.
  #discard-paths: yes
sedrik commented 1 year ago

It looks like you are moving the built binary to the current working directory with the initial move but the artifact is expected to reside inside of the trading-api folder so that is probably why it is not found.

Try changing - mv target/release/trading-api bootstrap to - mv target/release/trading-api trading-api/bootstrap

Hope it helps.

marcustut commented 1 year ago
Screenshot 2022-10-26 at 11 49 04 PM

I can't do that actually, it fails on CodeBuild because trading-api is not a folder there

marcustut commented 1 year ago

I'm using Function URLs here, could that be a culprit? I tried running the same build output from CodeBuild on EC2 and I have to use Nginx in order for it to be accessible from he public.

sedrik commented 1 year ago

Ok, what if you try.

...
- mv target/release/trading-api bootstrap
...
artifacts:
  files:
    - bootstrap

I dont use CodeBuild myself but it feels like that should work. I would guess that CodeBuild make anything you specify in the artifacts available somewhere for you to access