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

Update hitcounter handler to use SDK V3, lambda to use Node 18 runtime #1180

Open
1 of 2 tasks
scanlonp opened this issue Sep 22, 2023 · 3 comments
Open
1 of 2 tasks
Labels
effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1

Comments

@scanlonp
Copy link

General Information

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Description

Node 18 is the recommended runtime version for lambda functions running on Node. Changing the runtime requires the handler functions to use SDKv3.

Proposed Solution

Update the code and runtime.

CDK CLI Version

No response

Section

No response

Browser

No response

Language

No response

Other information

No response

@scanlonp scanlonp added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Sep 22, 2023
@estanqueiroa
Copy link

estanqueiroa commented Dec 15, 2023

facing this error message related to nodejs12.x version:

dkWorkshopStack: creating CloudFormation changeset...
7:21:52 PM | CREATE_FAILED | AWS::Lambda::Function | ViewHitCounterRendered9C783E45
Resource handler returned message: "The runtime parameter of nodejs12.x is no longer supported for creating or updating AWS Lambda functions. We recommend you use the new runtime (nodejs18.x) while creating or u
pdating functions. (Service: Lambda, Status Code: 400, Request ID: 612a17a9-c43a-4eae-addb-15345e953a90)" (RequestToken: 56c410cf-a9ec-de2d-bae1-51cffc6b446f, HandlerErrorCode: InvalidRequest)

step: https://cdkworkshop.com/30-python/50-table-viewer/500-deploy.html

@kami619
Copy link

kami619 commented Jan 4, 2024

When I am using the Node 20 runtime, I am forced to make updates to the aws-sdk to use V3 version and the way dynamodb and lamdba are defined in the hitcounter.js file is very different. This is hampering the progress of what I could because of the limited JS knowledge I have and defeats the purpose of the workshop when the content is outdated. @estanqueiroa thanks for raising this issue in the first place.

Issue I am hitting in the HitCounter api with the newer node run-time

2024-01-04T16:16:39.901Z	undefined	ERROR	Uncaught Exception 	
{
    "errorType": "Runtime.ImportModuleError",
    "errorMessage": "Error: Cannot find module 'aws-sdk'\nRequire stack:\n- /var/task/hitcounter.js\n- /var/runtime/index.mjs",
    "stack": [
        "Runtime.ImportModuleError: Error: Cannot find module 'aws-sdk'",
        "Require stack:",
        "- /var/task/hitcounter.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"
    ]
}

@ashishdhingra
Copy link
Contributor

@scanlonp Thanks for raising the issue. Feel free to contribute PR to use Node.js 18.x runtime.

@kami619 Node.js 20.x doesn't come with bundled AWS JS SDK v3, hence extra steps might be required.

@ashishdhingra ashishdhingra added effort/small Small work item – less than a day of effort p1 and removed needs-triage This issue or PR still needs to be triaged. labels Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p1
Projects
None yet
Development

No branches or pull requests

4 participants