node.jsamazon-web-servicesamazon-cognitoserverlessserverless-framework

Serverless Framework v3 custom-resource-existing-cup function Node16 is deprecated


I am using Serverless Framework (v3), and Node.js (v18). and it creates one lambda function (custom-resource-existing-cup) automatically if there is this line is added in the Cognito custom trigger lambda function. existing: true

It's okay, but the problem is this lambda function is using Node 16, even I use Node 18.

I tried to change the Node.js version for this custom lambda function, but I couldn't, because it's generated automatically by Serverless Framework. Is there anyway to solve this issue? Because it's deprecating soon.


Solution

  • The Lambda function for custom resources have nodejs16 runtime hardcoded. https://github.com/serverless/serverless/blob/d0e3056b77ba295adb87ceeca9a49a26b315f083/lib/plugins/aws/custom-resources/index.js#L165-L179

    const customResourceFunction = { 
       Type: 'AWS::Lambda::Function', 
       Properties: { 
         Code: { 
           S3Bucket, 
           S3Key, 
         }, 
         FunctionName: absoluteFunctionName, 
         Handler, 
         MemorySize: 1024, 
         Runtime: 'nodejs16.x', 
         Timeout: 180, 
       }, 
       DependsOn: [], 
     }; 
    

    I tried to edit the node_modules as this link, it works well.

    https://github.com/serverless/serverless/issues/12133#issuecomment-1958961198