DEV Community

Cover image for Deploy your first Node 20 Lambda function on AWS!

Deploy your first Node 20 Lambda function on AWS!

Pierre Chollet on November 13, 2023

TL;DR AWS released a public base image for Node 20 Lambda runtime last week. It is now possible to deploy Node 20 Lambda functions on AW...
Collapse
 
fmcdev profile image
fmcdev

I'd like to add a suggestion that got me crazy when trying to migrate AWS Lambda functions from nodejs 16 to nodejs 20. The issue is that aws-sdk changed from V2 to V3 in the meanwhile and AWS.util.uuid.v4() is not available anymore. You can solve using:
const { randomUUID: AWS_util_uuid_v4 } = require('crypto');
and then use AWS_util_uuid_v4() where you used AWS.util.uuid.v4() before. Hope this can help. Bye

Collapse
 
jlgouwy profile image
Gouwy Jean-louis

Do we know if there is an "official" release date for this runtime ?
Because we plan to migrate to node 18 ... but if the 20 is coming in few weeks, it should worth to wait for it.

Collapse
 
pchol22 profile image
Pierre Chollet

It should be available in a few days / weeks, given that Node 20 became LTS two weeks ago.

I would suggest you to wait for Node 20 if you can afford to delay your migration for at least one more month, to avoid instabilities in the first releases of the official managed runtime.

Collapse
 
pchol22 profile image
Pierre Chollet

Update: AWS just released the Node 20 managed runtime, available right now! (at least in eu-west-1 where I checked)

Collapse
 
nienow profile image
Matthew Nienow

Can you have the Lambda functions update automatically when you push new docker images?

Collapse
 
pchol22 profile image
Pierre Chollet

There is no obvious way to do so, it surely can be achieved by using some frameworks like SAM...
What you can easily do yourself is run this kind of command in your terminal just after you pushed the image :

aws lambda update-function-code \
           --function-name my-lambda \
           --image-uri 123456789.dkr.ecr.eu-west-1.amazonaws.com/my-image:latest
Enter fullscreen mode Exit fullscreen mode

with the tag of the image you just pushed. It will update the lambda from your CLI

Collapse
 
nienow profile image
Matthew Nienow

thanks for this tip

Collapse
 
dsaga profile image
Dusan Petkovic

I haven't worked with AWS lambdas before, but does each function need to be added via the GUI in aws?

Collapse
 
dsaga profile image
Dusan Petkovic

If a configuration file could be added where multiple functions can be defined or something?

Collapse
 
pchol22 profile image
Pierre Chollet

Also, I am currently writing a series where I start from the beginning, and use the AWS CDK to deploy my lambda functions programmatically. You can find the first article here : dev.to/slsbytheodo/dont-miss-on-th...

Collapse
 
pchol22 profile image
Pierre Chollet

Yes are many ways to deploy Lambda function without the CLI. I advise you to check the serverless framework, the AWS CDK or SST, that allow to do this programmatically using JS or TS.