Upgrading Node Version from 12.x to 16.x in AWS Lambda

Jeevan thomas koshy
Remote Serverless
Published in
2 min readSep 12, 2022

If you are running any AWS Lambda functions with Node version 12, you would probably have received an email from the AWS team asking to upgrade the Node version to 16. This is happening as a result of Node 12 reaching an End-of-Life on April 30, 2022. In this blog, I intend to cover the various methods by which you can upgrade the Node versions for your Lambda runtime.

Are you affected by this change?

  1. Find out the Node versions getting deprecated: You can use the End of Life service for this.
  2. Cross-check with your Lambda runtime versions: To track your current lambda runtime version, you can go to the Lambda Console on AWS and view the Runtime against the deployed lambda functions under the Runtime Tab.

How do we solve this?

Update Via AWS Console: If you use AWS Console to deploy your Lambda functions without using any IAC frameworks, you can directly update the Node version on the console. This setup is optimal for simple lambda functions without any external dependencies and only relying on AWS SDK for its business logic.
In such a scenario, follow these steps to update the Node version:

  • Go to the specific function
  • Scroll down to “Runtime settings”
  • Click on the Edit button and provide the Node version

Update via Serverless Framework: If you use the Serverless Framework to deploy your Lambda functions, you can update the runtime configuration by updating the runtime field under the provider section. Make sure to run npm install and also update all outdated packages before deploying the code using the serverless deploy command. You can make use of the npm outdated command to figure out outdated packages.

Update via AWS CDK: If you are using the AWS CDK for deploying your Lambda functions, update the runtime field under NodejsFunctionProps to Runtime.NODEJS_16_X. Just like in the previous setup with the Serverless framework, make sure to run npm install and also update all outdated packages before deploying.

Best Practices for Local Setup

On your local machine, in order to manage different versions of Node, use NVM. In general, it is a good practice to have a file called .nvmrc with the node version of the project. If you have NVM setup, run nvm use before updating npm packages and deploying.

That’s pretty much everything I wanted to cover. If you found this useful, please do subscribe to the Remote Serverless publication as we are planning to continuously create useful content around the Serverless Space. If you need help with an ongoing project or want to build a new project from scratch feel free to reach out to us and we will be happy to help.

--

--

Jeevan thomas koshy
Remote Serverless

Senior Software Engineer | Freelancer | Aws Certified Developer