Lambda Function NodeJS version always reverted to 12.x - node.js

I am running javascript Lambda functions that required NodeJS version 14.x. I can manually set this in the AWS Lambda console here (screenshot below), but every time I use the amplify CLI to push a change of the function, it gets reverted back to 12.x. I can't find any reference to the NodeJS version in the local amplify files, or online. Is there a way to keep it from reverting every time?
This is what the Lambda console option looks like, which I edit to 14.x constantly, but it changes back to 12.x:

Currently (26 July 2021), AWS Amplify only support NodeJS ver 12.x. Please see the Supported Lambda runtimes paragraph in the Amplify Docs for reference.

While #matsev's answer looks to be the official version supported by AWS, I noticed that while some of my functions continued to be reverted to 12.x, others stayed at 14.x even after a push. The ones that stayed at 14.x were my more recently created functions.
It turns out, you can edit the *.cloudformation-template.json for each function to set the nodejs version! This file did not appear in my vscode search due to a previous developer hiding it using files.exclude. This is likely a good best practice because the file is meant to be just edited using the amplify CLI, but there are obviously some settings that are not part of the CLI commands. Another example is the timeout parameter in here.
The file is located at: amplify/backend/function/FUNCTION_NAME/FUNCTION_NAME-cloudformation-template.json
The parameter to edit is: `Resources.LambdaFunction.Properties.Runtime = "nodejs14.x"

Related

How do I get exact version numbers of NodeJS my AWS lambda currently supports?

How do I get the exact versions of Node.js, e.g. 18.1.2 that I can run on AWS lambda? The documentation gives me 18.x which is not very specific.
Seems like:
AWS doesn't show node.js version in the UI, so you need to console.log(process.version)
the version can change at any time, no one will notify you

Amazon AWS S3 autoDeleteObjects lambda

Could you please help me understand how to specify the nodejs runtime version of the lambda function that gets automatically created by aws when a new data bucket with parameter
autoDeleteObjects: true is created?
I am using the following piece of code:
const autoDeleteBucketProps = { autoDeleteObjects: true, removalPolicy: >cdk.RemovalPolicy.DESTROY };
new Bucket(this, 'store', {
...bucketProps,
...autoDeleteBucketProps
});
This code automatically creates a lambda function with runtime version Node.js 12.x for autodeleting objects. However due to the fact that Amazon requires that we upgrade our lambda runtimes (ending support of v12 as described in Lambda runtime support policy), I am trying to a find a way to upgrade the runtime of this automatically created lambda to version 14.
I am using aws-cdk v1.152.0 which supports '#aws-cdk/aws-lambda' Runtime version v14. So why this lambda gets created with runtime v12? And how can it can be changed to v14, programmatically?
Thank you in advance.
I just updated one of our stacks from CDK 2.23.0 to 2.46.0 and the auto deletion lambda automatically updated to Node 14 runtime.
You said you were using CDK 1.152.0 and if for some reason you want to stick with V1, it should also update to the new runtime in 1.176.0, but I have not tested this myself. I was just reading the changelog notes of CDK.
Updating to CDK v2 was quite easy for us at least and I think v1 is nearing end-of-life so I suggest you move to v2 now or soon.
I think you should be able to update the runtime in the console or remake the function when v12 is no longer used.
You can find more details on the lambda runtimes here

AWS Serverless Image Handler - Version 5 - Lambda running on Node.js 12 End of Life

I've recently taken over a project that has AWS Serverless Image Handler version 5 implemented. And I've been sent various emails from the client they received about Node.js v12 hitting end of life and the Lambda functions needing to run on a new Node.js runtime.
Having a looking through the AWS account, I've seen I can just switch the runtime to Node.js v14 or v16, but do I need to do any code updates?
Sorry a complete noob to Lambda, and the CloudFormation stacks etc
Thought I would ask before I jump down the rabbit hole and look at setting up my own copy of Serverless Image Handler and doing some testing, or even trying to implement version 6.
This depends of the code / imported libraries in the Serverless Image Handler Lambda.
I would check if there are breaking changes in Node14, that could affect the code.
This does not have anything to do with Lambda / CF itself.

How to check minor Node.js version in AWS Lambda and Elasticbeanstalk?

I'm relying on Node version 12.17.x to make use of a specific feature (AsyncLocalStorage) in Lambda and Elasticbeanstalk. But for some reason, the Node.js version does not seem to publicly available. Why do they think that platform "12.x" tells me the real Node version? I want to know the exact minor and patch version, or at least give some news about it...
I had to create a test lambda function that prints process.version, but surprisingly, platform 12.x still uses v12.16. When will they upgrade to the latest stable version that came out more than 2 weeks ago? Are they publishing those releases somewhere? Google tells me nothing useful.
The same applies to Elasticbeanstalk instances. Node v12.17 does not exist in /opt/elasticbeanstalk/node-install/*
I've just checked in our sentry and the current version is newer-v12.18.4 so you can safely use AsyncLocalStorage now on v12 lambdas.
But AWS should really show this in the lambda administration panel. The fact that this is not shown anywhere and we have to use console logs or third party tools to get this info is a very poor DX.

Online-Edit Amazon Lambda function with alexa-sdk

I am creating an Alexa skill and I am using Amazon Lambda to handle the intents. I found online several tutorials and decided to use NodeJs with the alexa-sdk. After installing the alexa-sdk with npm, the zipped archive occupied a disksize of ~6MB. If I upload it to amazon, it tells me
The deployment package of your Lambda function "..." is too large to enable inline code editing. However, you can still invoke your function right now.
My index.js has a size of < 4KB but the dependencies are large. If I want to change something, I have to zip it altogether (index.js and the folder with the depencencies "node_modules"), upload it to Amazon and wait till its processed, because online editing isn't available anymore. So every single change of the index.js wastes > 1 minute of my time to zip and upload it. Is there a possibility to use the alexa-sdk dependency (and other dependencies) without uploading the same code continually every time I am changing something? Is there a possibility to use the online-editing function though I am using large dependencies? I just want to edit the index.js.
If the size of your Lambda function's zipped deployment packages
exceeds 3MB, you will not be able to use the inline code editing
feature in the Lambda console. You can still use the console to invoke
your Lambda function.
Its mentioned here under AWS Lambda Deployment Limits
ASK-CLI
ASK Command Line Interface let you manage your Alexa skills and related AWS Lambda functions from your local machine. Once you set it up, you can make necessary changes in your Lambda code or skill and use deploy command to deploy a skill. The optional target will let you deploy the associated Lambda code.
ask deploy [--no-wait] [-t| --target <target>] [--force] [-p| --profile <profile>] [--debug]
More info about ASK CLI here and more about deploy command here

Resources