Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

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

Closed
1 of 2 tasks
scanlonp opened this issue Sep 22, 2023 · 4 comments
Closed
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
@kellertk kellertk closed this as completed Aug 1, 2024
Copy link

github-actions bot commented Aug 1, 2024

⚠️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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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

5 participants