awsdocs / aws-cdk-guide

User guide for the AWS Cloud Development Kit (CDK).
Other
327 stars 222 forks source link

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

Closed markusl closed 1 year ago

markusl commented 1 year ago

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

Proposal:

Hustenbonbon commented 1 year ago

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

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

markusl commented 1 year ago

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 https://github.com/aws/aws-cdk/issues/23333

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

Hustenbonbon commented 1 year ago

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.