Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 655 Vote(s) - 3.46 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"invalid ELF header" when using the nodejs "ref" module on AWS Lambda

#1
I've just uploaded a zip to AWS Lambda which included the "ref" (

[To see links please register here]

), which is needed to validate an iOS Game Center authentication token (

[To see links please register here]

).

Unfortunately invoking it results in the "invalid ELF header" error,

{
"errorMessage": "/var/task/node_modules/ref/build/Release/binding.node: invalid ELF header",
"errorType": "Error",
"stackTrace": [
"Module.load (module.js:356:32)",
"Function.Module._load (module.js:312:12)",
"Module.require (module.js:364:17)",
"require (module.js:380:17)",
"bindings (/var/task/node_modules/ref/node_modules/bindings/bindings.js:76:44)",
"Object.<anonymous> (/var/task/node_modules/ref/lib/ref.js:5:47)",
"Module._compile (module.js:456:26)",
"Object.Module._extensions..js (module.js:474:10)",
"Module.load (module.js:356:32)",
"Function.Module._load (module.js:312:12)"
]
}

This has been developed on a 64bit Macbook Pro running Yosemite which has no problem running the code locally. Googling around for "invalid ELF header" has yielded little to know relevant results and I'm really not sure where to go from here. Would I be better asking this in a node.js area, or is this the relevant area, because it might be an issue with the platform?
Reply

#2
This happens when you build on one architecture and then attempt to use the same built addon on a different architecture (or platform in some cases).

According to [this page](

[To see links please register here]

), addons may have to be compiled against an Amazon Linux image on EC2 in order for the compiled addons to be usable on their Lambda service.
Reply

#3
This doesn't apply exactly to your question, but in case anyone stumbles across this when using AWS Elastic Beanstalk, it could be a result of uploading the `node_modules/` directory along with everything else, so you need to force it to ignore the file.

### `.ebignore`
node_modules/
Reply

#4
Here is the answer to your question that I found on [Reddit](

[To see links please register here]

):

[SOLVED BY JeffGebhart]

[To see links please register here]


Then SSH into EC2 instance running Amazon Linux 2.

- Install `npm` with `nvm` and `docker` and run
```
docker pull lambci/lambda
```
- run
```
mkdir LambdaFunction
```

- run
```
npm init
```
and initialize everything.

- then you need to be in that folder and run

```
docker run --rm -v "$PWD":/var/task lambci/lambda:build-nodejs12.x
npm install <packages you need>
```
and it will build prover native modules in `node_modules`. Now you can extract all files to your PC or to your AWS.
Reply

#5
For those Developers porting JS to TypeScript on Lambda, ensure ALL dependancies are imported, not required:

import $ from "cheerio";

NOT

const $ = require("cheerio");
Reply

#6
Again, for anyone close to tears on this issue, try individually packaging your functions:

> serverless.ts /.yml

Blockquote

package: {
individually: true
},
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through