awsdocs/aws-cdk-guide

"Creating a serverless application using the AWS CDK" is using outdated AWS Lambda runtime and old version of AWS JS SDK

Closed this issue · 3 comments

"Creating a serverless application using the AWS CDK" is using outdated AWS Lambda runtime and old version of AWS JS SDK

Proposal:

  • Update AWS Lambda to NODEJS_18_X
  • Update AWS JS SDK to v3

This fix is broken and leads to crashing lambdas, returning internal server error.|
Bugs I found so far:

  • Using import syntax without a package.json
  • Only fixing the second version of widget.js, not the first

If you update an entry-level guide, please test it before.

Thanks for noticing this. As noted, the code itself does work, but requires using one of the documented options:

Authors can tell Node.js to use the ECMAScript modules loader via the .mjs file extension, the package.json "type" field, or the --input-type flag

In CDK, there is support for ECMAScript modules and this could be worth mentioning also in this page since people likely run into the issue when developing. See also aws/aws-cdk#23333

@lizsnyder is looking into the possibility of updating the first version of the code. See comment at awsdocs/aws-doc-sdk-examples#4663

Thanks for reacting that quick. My intention was to make this part of the guide (as the content of the lambdas are not the focus) as easy-to-use as possible.
I saw that there is an update, I would consider my suggested changes to your update as a hotfix, so it works out of the box in the context of the guide until the guide is updated.

Thanks for the attached links, they are very helpful to further understand the problem space.