Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I safely update my AWS Lambda functions' runtime from Node.js 12 to Node.js 16?

I recently got an email from AWS detailing the deprecation of Node.js 12. So, I updated the runtime of my Lambda functions by, in the AWS Console, going to Lambda > Functions > [My Function]. In the Code tab, there's a section called Runtime settings. There, I changed Runtime from Node.js 12x to Node.js 16x.

This modification has not broken any of my Lambda functions. However, I'm not sure whether I should also change CloudFormation Templates, or if there's any other requirements for changing the runtime of a Lambda function.

Any help would be greatly appreciated. Thank you!

like image 510
elishapiro Avatar asked Dec 19 '25 16:12

elishapiro


1 Answers

For AWS Amplify projects, look for the "Runtime": property in each amplify/backend/function/YOURLAMBDA/yourlambda-cloudformation-template.json file and update it.

It's probably nodejs14.x so you can search for that and just bump it to 16.

This snippet demonstrates settings for Node 16, uses the 'Graviton' processor (can be faster/cheaper), bumps the timeout a smidge, and increases memory:

"Runtime": "nodejs16.x",
"Architectures": [
  "arm64"
],
"Layers": [],
"MemorySize": 256,
"Timeout": 60

You only need to modify the Runtime line.

With respect to "safely", the above is the correct way to update the runtime, and the change will propagate to new 'environments' as you deploy them. If you edit the setting directly via the console, it will (probably) be overwritten the next time you deploy an updated lambda.

Be sure to test your changes in dev just as you would when updating to a new node package. I'm sure it's obvious that switching runtimes (and/or the architecture) can introduce subtle bugs if your code behaves slightly differently when running against Node 16.

like image 149
Dave Avatar answered Dec 21 '25 05:12

Dave



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!