Node 18 tries to import aws-sdk

0

I've recently upgrade lamdba to node 18 and some of the functions seem to be throwing the following error. I am no longer using the 'aws-sdk' but the '@aws-sdk/client' v3 versions

{
    "errorType": "Runtime.ImportModuleError",
    "errorMessage": "Error: Cannot find module 'aws-sdk'\nRequire stack:\n- /var/task/api/v1/onboarding/registerEmail/handler.js\n- /var/runtime/index.mjs",
    "stack": [
        "Runtime.ImportModuleError: Error: Cannot find module 'aws-sdk'",
        "Require stack:",
        "- /var/task/api/v1/onboarding/registerEmail/handler.js",
        "- /var/runtime/index.mjs",
        "    at _loadUserApp (file:///var/runtime/index.mjs:1061:17)",
        "    at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1093:21)",
        "    at async start (file:///var/runtime/index.mjs:1256:23)",
        "    at async file:///var/runtime/index.mjs:1262:1"
    ]
}

2回答
0
承認された回答

Turns out there was a layer attacked to some of the functions which tried to use the 'aws-sdk'

Sven
回答済み 8ヶ月前
0

If your existing Lambda functions are using the included SDK v2, then you must update your function code to use the SDK v3 when upgrading to the Node.js 18 runtime. This is the recommended approach when upgrading existing functions to Node.js 18. Alternatively, you can use the Node.js 18 runtime without updating your existing code if you deploy the SDK v2 together with your function code.

Reference :

  1. https://aws.amazon.com/blogs/compute/node-js-18-x-runtime-now-available-in-aws-lambda/
  2. https://aws.amazon.com/blogs/developer/why-and-how-you-should-use-aws-sdk-for-javascript-v3-on-node-js-18/
profile pictureAWS
エキスパート
回答済み 8ヶ月前
  • As I mentioned, the functions are no longer use the SDK v2.

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ