aws-samples/aws-cdk-intro-workshop

Error executing the hitcounter.js lamba

Closed this issue · 5 comments

Describe the bug

Once deployed and test the hitcounter.js construct part I am getting an import error at runtime.
Not able to find the required aws-cdk lib.

{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module 'aws-cdk'\nRequire stack:\n- /var/task/hitcounter.js\n- /var/runtime/UserFunction.js\n- /var/runtime/Runtime.js\n- /var/runtime/index.js",
"trace": [
"Runtime.ImportModuleError: Error: Cannot find module 'aws-cdk'",
"Require stack:",
"- /var/task/hitcounter.js",
"- /var/runtime/UserFunction.js",
"- /var/runtime/Runtime.js",
"- /var/runtime/index.js",
" at _loadUserApp (/var/runtime/UserFunction.js:225:13)",
" at Object.module.exports.load (/var/runtime/UserFunction.js:300:17)",
" at Object. (/var/runtime/index.js:43:34)",
" at Module._compile (internal/modules/cjs/loader.js:1085:14)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)",
" at Module.load (internal/modules/cjs/loader.js:950:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:790:12)",
" at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)",
" at internal/main/run_main_module.js:17:47"
]
}

Expected Behavior

To be able to run the workshop hitcounter part

Current Behavior

Fails to invoke the lamba

Reproduction Steps

Did the workshop step by step until
Use the hit counter
and see the logs

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

No response

Section

Hit counter handler

Browser

all

Language

TypeScript

I think there's a typo in your code, in hitcounter.js, aws-sdk is used, not aws-cdk.
Also, if you're using node.js v18, try using @aws-sdk/client-lambda and @aws-sdk/client-dynamodb instead.

Thank you @HAoRAn-W for for spotting that.

Did that resolve your issue @luistrigueiros?

Hi @peterwoodworth
Thank you @HAoRAn-W helped me with this one it was just a typo from my part thank you.

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.