assertible / lambda-cloudwatch-slack

Send AWS CloudWatch notifications to a Slack channel using Lambda
https://assertible.com/blog/npm-package-lambda-cloudwatch-slack
MIT License
482 stars 249 forks source link

AWS no longer support Node.js 12 #77

Open AustinAMeyer opened 1 year ago

AustinAMeyer commented 1 year ago

Hello,

This is currently broken because AWS no longer support Node.js 12. Please upgrade this to a newer version of Node.js so that this application remains functional. It really is a great tool and I would love to continue using it. I appreciate your help!

Thanks, Austin

AustinAMeyer commented 1 year ago

Here is the error message: The runtime parameter of nodejs12.x is no longer supported for creating or updating AWS Lambda functions. We recommend you use the new runtime (nodejs18.x) while creating or updating functions. => Retrying InvalidParameterValueException: The runtime parameter of nodejs12.x is no longer supported for creating or updating AWS Lambda functions. We recommend you use the new runtime (nodejs18.x) while creating or updating functions.

anil-venkata commented 1 year ago

I solved it by following these steps , may be the hacky way.

1) Install node 18 in your local 2) remove the package-lock.json (not really required, for the sake of it i did) 3) run npm install 4) go to this folder cd ./node_modules/node-lambda/bin/ 5) Open the file in your favourite text editor and replace the line const AWS_RUNTIME = process.env.AWS_RUNTIME || 'nodejs12.x' to const AWS_RUNTIME = process.env.AWS_RUNTIME || 'nodejs18.x' , save the file 6) go to root dir of this repo and run the command npm run deploy

And it worked for me

dhanvi commented 7 months ago

Setting the below in .env did the trick for me.

AWS_RUNTIME=nodejs18.x

HieronyM commented 7 months ago

I got this error after try to deploy it on node18 & node20

{
  "errorType": "TypeError",
  "errorMessage": "Cannot read properties of undefined (reading '0')",
  "trace": [
    "TypeError: Cannot read properties of undefined (reading '0')",
    "    at processEvent (/var/task/index.js:359:43)",
    "    at exports.handler (/var/task/index.js:418:5)",
    "    at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1173:29)"
  ]
}
bensebborn commented 7 months ago

All you need to do is change the version of lambda-node.

In your package.json change

"node-lambda": "0.16.0"

to

"node-lambda": "1.3.0"