aws-samples / aws-samples/s3-to-lambda-patterns

Updating Nodejs, causing error in Lambda function

Open
#40 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
222
Forks
134
PR merge metrics
No merged PRs in 30d

Description

I was forced to update the node.js version, due to getting an error message saying that Lambda no longer supported the version referenced on this repository. Updated to version 22. When testing the Lambda on AWS I am getting the error included below. I am not a java dev so I would welcome updated app.js / package.json with corrected syntax.

Response:
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module 'aws-sdk'\nRequire stack:\n- /var/task/app.js\n- /var/runtime/index.mjs",
"trace": [
"Runtime.ImportModuleError: Error: Cannot find module 'aws-sdk'",
"Require stack:",
"- /var/task/app.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"
]
}

Function Logs:
2025-05-15T10:45:12.017Z undefined ERROR Uncaught Exception {"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module 'aws-sdk'\nRequire stack:\n- /var/task/app.js\n- /var/runtime/index.mjs","stack":["Runtime.ImportModuleError: Error: Cannot find module 'aws-sdk'","Require stack:","- /var/task/app.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"]}
INIT_REPORT Init Duration: 86.51 ms Phase: invoke Status: error Error Type: Runtime.ImportModuleError
START RequestId: edaec6c5-fd34-41e5-b865-a3d85ceb52b9 Version: $LATEST
END RequestId: edaec6c5-fd34-41e5-b865-a3d85ceb52b9
REPORT RequestId: edaec6c5-fd34-41e5-b865-a3d85ceb52b9 Duration: 98.20 ms Billed Duration: 99 ms Memory Size: 128 MB Max Memory Used: 75 MB Status: error Error Type: Runtime.ImportModuleError

Request ID: edaec6c5-fd34-41e5-b865-a3d85ceb52b9

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.