theam / aws-lambda-haskell-runtime

⚡Haskell runtime for AWS Lambda
https://theam.github.io/aws-lambda-haskell-runtime/
Other
269 stars 48 forks source link

Linking error #90

Closed blackheaven closed 3 years ago

blackheaven commented 3 years ago

Hi all,

After following the tutorial: https://theam.github.io/aws-lambda-haskell-runtime/06-deploying-a-lambda.html

I ended with a lambda function I have configured with the Custom runtime.

When I try to make a test call, I have got this error:

START RequestId: 29389b30-aff6-46be-9e9c-f8e3fa859bf3 Version: $LATEST
/var/task/bootstrap: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by /var/task/bootstrap)
END RequestId: 29389b30-aff6-46be-9e9c-f8e3fa859bf3
REPORT RequestId: 29389b30-aff6-46be-9e9c-f8e3fa859bf3  Duration: 35.17 ms  Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 6 MB   
RequestId: 29389b30-aff6-46be-9e9c-f8e3fa859bf3 Error: Runtime exited with error: exit status 1
Runtime.ExitError

I use stack with the lts-16.8.

Have you got any insight regarding that ?

Thanks by advance.

NickSeagull commented 3 years ago

Hello, thanks for reporting this!

Were you following the tutorial step by step? I'm asking to have in mind if you might have added some additional steps that could introduce additional libraries.

It looks like your project is not being properly linked, something similar happens when deploying Rust code aswell (search for GLIBC in this post )

Could you please write the process you followed to deploy?

Thanks a lot 😄

blackheaven commented 3 years ago

Hello, thank you for your answer.

Here are the steps I have taken:

I prepare the zip file on my computer:

stack build --docker
cp $(stack --docker path --local-install-root)/bin/user-management-bootstrap build/
cd build && mv user-management-bootstrap bootstrap && zip user-management-function.zip bootstrap && rm bootstrap && cd ..

Then I go to the AWS Lambda console, I upload the zip file and edit the configuration to get this:

settings config

The only diverging part is the handler name, is it "hard coded"?

Alternatively I was considering building it statically, WDYT?

blackheaven commented 3 years ago

Well, static linking seems to be a workaround, but I would like to solve it if you have any hints.

NickSeagull commented 3 years ago

Right now I have no idea how to fix this in this way, all compiled runtimes seem to use static linking.

dnikolovv commented 3 years ago

This is because you need to build the bootstrap executable in the same environment as you would run it.

stack build --docker uses the FP Complete images for the build, but when running a Lambda you're running in their Amazon flavored Linux, thus you get library discrepancies.

You can work around it by using the lambci/lambda build images.

E.g.

FROM lambci/lambda:build-provided

# Installing basic dependencies
RUN yum install -y postgresql-devel # or whatever

# Installing Haskell Stack
RUN sudo curl -sSL https://get.haskellstack.org/ | sh

WORKDIR work

COPY . .

RUN stack build

# ... you get the point

ENTRYPOINT sh

If you want dynamically linked libraries it can be tricky, if you have trouble ping me.