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

Feat: Deploy AWS Lambda Function with URL #128

Open
4 tasks done
nelsonic opened this issue Jan 17, 2024 · 6 comments
Open
4 tasks done

Feat: Deploy AWS Lambda Function with URL #128

nelsonic opened this issue Jan 17, 2024 · 6 comments

Comments

@nelsonic
Copy link
Owner

nelsonic commented Jan 17, 2024

We need a way of invoking the scraper from our Elixir app for dwyl/who#86

Todo

  • allow a single url variable
  • return data as JSON

Note: Only working on the "happy path".

Ref: dwyl/learn-aws-lambda#124 -> https://dev.to/aws-builders/introducing-lambda-function-urls-4ahd

@nelsonic
Copy link
Owner Author

nelsonic commented Feb 4, 2024

Getting a roadblock:

distpath: tmp/dist/
node:child_process:965
    throw err;
    ^

Error: Command failed: zip -rq -X tmp/github-scraper.zip ./
    at checkExecSyncError (node:child_process:890:11)
    at Object.execSync (node:child_process:962:15)
    at module.exports (/github-scraper/node_modules/dpl/lib/exec_sync.js:5:23)
    at Object.zip (/github-scraper/node_modules/dpl/lib/zip.js:19:3)
    at Object.<anonymous> (/github-scraper/node_modules/dpl/dpl.js:12:5)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12) {
  status: 15,
  signal: null,
  output: [
    null,
    'zip I/O error: No such file or directory\n' +
      'zip error: Could not create output file (tmp/github-scraper.zip)\n',
    ''
  ],
  pid: 63403,
  stdout: 'zip I/O error: No such file or directory\n' +
    'zip error: Could not create output file (tmp/github-scraper.zip)\n',
  stderr: ''
}

Node.js v20.11.0

@nelsonic
Copy link
Owner Author

nelsonic commented Feb 4, 2024

Working:
https://eu-west-1.console.aws.amazon.com/lambda/home?region=eu-west-1#/functions/github-scraper-v7?tab=testing
image

But I'm burning the candle at both ends working at 3am ... so calling it a day. 🛌

@nelsonic
Copy link
Owner Author

https://eu-west-1.console.aws.amazon.com/lambda/home?region=eu-west-1#/functions/github-scraper-v7?tab=testing
image

{
  "errorType": "Runtime.ImportModuleError",
  "errorMessage": "Error: Cannot find module '../config/repos'\nRequire stack:\n- /var/task/lib/followers.js\n- /var/task/lib/scrapers.js\n- /var/task/lib/switcher.js\n- /var/task/lib/index.js\n- /var/task/index.js\n- /var/runtime/index.mjs",
  "trace": [
    "Runtime.ImportModuleError: Error: Cannot find module '../config/repos'",
    "Require stack:",
    "- /var/task/lib/followers.js",
    "- /var/task/lib/scrapers.js",
    "- /var/task/lib/switcher.js",
    "- /var/task/lib/index.js",
    "- /var/task/index.js",
    "- /var/runtime/index.mjs",
    "    at _loadUserApp (file:///var/runtime/index.mjs:1087:17)",
    "    at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1119:21)",
    "    at async start (file:///var/runtime/index.mjs:1282:23)",
    "    at async file:///var/runtime/index.mjs:1288:1"
  ]
}

@nelsonic
Copy link
Owner Author

Basic lambda function is working:
image

@nelsonic
Copy link
Owner Author

Working! 🎉
image

Not sharing the URL just yet as want to avoid spam. But I'm optimistic this will work. 💭

@nelsonic
Copy link
Owner Author

This is already what I needed ...

image

Now I need to use it ... 💭

nelsonic added a commit that referenced this issue Apr 23, 2024
@nelsonic nelsonic mentioned this issue Apr 23, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant