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

node 18.x support #144

Open
clarson opened this issue Apr 30, 2023 · 9 comments · May be fixed by #146
Open

node 18.x support #144

clarson opened this issue Apr 30, 2023 · 9 comments · May be fixed by #146

Comments

@clarson
Copy link

clarson commented Apr 30, 2023

Hi,

This script does not work when lambda is configured to run node 18. AWS lambda node 18 is using AWS SDK v3 and the require statement no longer works.

More information here:
https://aws.amazon.com/blogs/compute/node-js-18-x-runtime-now-available-in-aws-lambda/

Thanks,
Chuck

@ellis-sutehall
Copy link

I'm having the same problem. I had to update my script and SES forced my to upgrade the node version and now it doesn't work.

Were you able to fix it?

@clarson
Copy link
Author

clarson commented May 13, 2023

I was able to go back to node 16 which is still supported. I just checked before this reply.

lpsinger added a commit to lpsinger/aws-lambda-ses-forwarder that referenced this issue Jun 6, 2023
@lpsinger lpsinger linked a pull request Jun 6, 2023 that will close this issue
lpsinger added a commit to lpsinger/aws-lambda-ses-forwarder that referenced this issue Jun 7, 2023
lpsinger added a commit to lpsinger/aws-lambda-ses-forwarder that referenced this issue Sep 3, 2023
@mylesboone
Copy link

Here's code that will run on Node 18.x and uses SES v1 client:

https://gist.github.com/mylesboone/b6113f8dd74617d27f54e5d0b8598ff7

@Minjun-KANG
Copy link

Here's code that will run on Node 18.x and uses SES v1 client:

https://gist.github.com/mylesboone/b6113f8dd74617d27f54e5d0b8598ff7

error: PermanentRedirect: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.

You may encounter the above error message.
In this case, you can set the region in S3 as shown below.
Thank you for sharing the code.

s3: overrides && overrides.s3 ?
overrides.s3 : new S3Client({signatureVersion: 'v4', region: 'ap-northeast-2'})

@arithmetric
Copy link
Owner

Thanks for this report! I've updated the documenation to recommend using the Node.js 16 runtime for now: 67bc86b

However I also found that the code works in Node.js 18 as is if you install the AWS SDK v2 module and its dependencies.

To do this, change the following step in the documented Set Up process:

For the Lambda function code, either copy and paste the contents of index.js into the inline code editor or zip the contents of the repository and upload them directly or via S3.

To do the following instead:

  1. In a copy of this repository, run npm i --omit=dev
  2. Create a .zip file with the contents of this repository. Note: index.js should be at the root of the zip file and not in a directory.
  3. Upload the zip file to Lambda.

Let me know if this approach works for you.

@lvn1
Copy link

lvn1 commented Nov 28, 2023

Here's code that will run on Node 18.x and uses SES v1 client:

https://gist.github.com/mylesboone/b6113f8dd74617d27f54e5d0b8598ff7

I managed to get it working in Node.js 18 by modifying the gist and only using the lambda code editor, without installing any additional dependencies.

CloudWatch errors were showing:

  • require is not defined in ES module scope, you can use import instead
  • exports is not defined in ES module scope

I just updated the import statements, changed the 5 exports to consts and changed the exports.handler to export const handler.

https://gist.github.com/lvn1/9814d301bead8e0ecfc79ba9efe64b4a

adamb924 added a commit to adamb924/aws-lambda-ses-forwarder that referenced this issue Jan 1, 2024
Not my work. Following guidance/code/links found here: arithmetric#144
@hacnet
Copy link

hacnet commented May 4, 2024

Here's code that will run on Node 18.x and uses SES v1 client:
https://gist.github.com/mylesboone/b6113f8dd74617d27f54e5d0b8598ff7

I managed to get it working in Node.js 18 by modifying the gist and only using the lambda code editor, without installing any additional dependencies.

CloudWatch errors were showing:

  • require is not defined in ES module scope, you can use import instead
  • exports is not defined in ES module scope

I just updated the import statements, changed the 5 exports to consts and changed the exports.handler to export const handler.

https://gist.github.com/lvn1/9814d301bead8e0ecfc79ba9efe64b4a

The 2nd gist presumably needs to have line 3-4 replaced with that of the 1st link.

It then still fails where export const handler is unexpected and/or related steps need further modification.

@mylesboone
Copy link

@hacnet I'd suggest using #147

@hacnet
Copy link

hacnet commented May 4, 2024

@hacnet I'd suggest using #147

That fixed it, many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants