hummusRecipe icon indicating copy to clipboard operation
hummusRecipe copied to clipboard

Invalid ELF Header on Lambda Function

Open giocodebot opened this issue 3 years ago • 5 comments

Hi! I hope you can help me, I'm trying to run it on a Lambda funtion running NodeJS 12.x but when I call it I receive the following error, thank you! image

giocodebot avatar Sep 02 '20 21:09 giocodebot

Can you post this in muhammara as well? It seems to me it's a hummusJS related issue.

chunyenHuang avatar Sep 02 '20 23:09 chunyenHuang

@giocodebot I overcame the issue by creating a separate layer for the HummusRecipe + Muhammara packages and repackaging it using a LambCI docker image (clear your .node_modules beforehand):

docker run --rm -v "$PWD":/var/task lambci/lambda:build-nodejs12.x npm install
mkdir .output
docker run --rm -v "$PWD":/var/task lambci/lambda:build-nodejs12.x zip -r --symlinks .output/output.zip . -x '*.git*' -x '*.output*'

I use a separate layer to avoid tedious repackaging on every change

lkowalski-smartbusiness avatar Sep 17 '20 10:09 lkowalski-smartbusiness

@lkowalski-smartbusiness When you say you create a seperate layer - do you mean with only the HummusRecipe + Muhammara in it, or do you mean your project as a whole and then the output.zip is uploaded as your main project on the lambda?

midnite81 avatar Sep 30 '20 09:09 midnite81

@midnite81 I meant just the HummusRecipe + Muhammara but I stand corrected as there were various issues to that approach (most likely some libraries overlapping in the layer and the actual lambda function that was built the normal way, haven't had the time to investigate deeply). What I did for it to work "right here, right now" is:

  • delete the node_modules directory (if one exists) for the function using HummusRecipe
  • run just the first command from my previous snippet (docker run --rm -v "$PWD":/var/task lambci/lambda:build-nodejs12.x npm install)
  • perform regular lambda deployment, if it includes build phase the installed modules will not get overwritten (as long as the versions still align!)

I'll be following up with my findings for a proper layer with just the libraries packaged in it when I do find the time to debug it properly.

lkowalski-smartbusiness avatar Sep 30 '20 09:09 lkowalski-smartbusiness

hey, this is mostly an architecture error, like you are compiling or bundling the muhammara binary on a windows machine and then upload it to lambda. This would not work as it is a binary compiled for a specific target architecture / libc.

similar issues are here: https://github.com/julianhille/MuhammaraJS/issues/155 or here https://github.com/julianhille/MuhammaraJS/issues/154

julianhille avatar Dec 16 '22 17:12 julianhille