AWS Lambda - nodejs12.x is no longer supported


today, when i tried to update one of my functions with:
sls deploy -f myFunction --config serverless-system.yml

i got: The runtime parameter of nodejs12.x is no longer supported for creating or updating AWS Lambda functions

i have updated my yaml to:
runtime: nodejs18.x

but it still dosnt let me update my function.

when changing the runtime in the aws website it let me update the function but after the update i get:
Runtime.ImportModuleError: Error: Cannot find module ‘aws-sdk’"

in my yaml i have:
- aws-sdk

my questions are:

  1. how to update a single function runtime through the cli?
  2. how to fix the aws-sdk error ?
  3. In general, is there any breaking changes between Node 18 and Node 12, disregarding external packages?

this is my setup:

Framework Core: 1.59.1
Plugin: 3.8.4
SDK: 2.3.2
Components Core: 1.1.2
Components CLI: 1.5.2

it is a very big project with lots of functions, and i really trying to avoid from updating the all stack.


I don’t remember all of the changes but they did switch the AWS SDK from v2 to v3. You might want to try using nodejs14.x or nodejs16.x to get away from 12 then do a proper upgrade when you have time.

thank you for your reply.
I think also to start from 16.
do you know how to update the runtime of a single function from the cli?

You could set the runtime parameter for just that function then deploy using Serverless. Is that what you mean?

yes, but how to do that not through the aws web console ?
I mean, for one function it’s ok, but i am updating functions all the time.
is there a way to update the run time of all the functions without publish a new version of the functions?
then it will give me to update every function i want whenever i want.

If you deployed the functions using Serverless then you should update them using Serverless. Doing it through the console will cause your CloudFormation stacks to be out of sync with your AWS account and can cause problems later.