[CloudFormation Deployment Failure] Nodejs10.x is no longer supported in AWS Lambda
mohamed-ali opened this issue · comments
Describe the bug
End of support of node.js 10x on AWS Lambda has been reached on July 30, 2021. So installing the stack referred to here: https://docs.aws.amazon.com/solutions/latest/document-understanding-solution/automated-deployment.html fails with the following error
Resource handler returned message: "The runtime parameter of nodejs10.x is no longer supported for creating or updating AWS Lambda functions. We recommend you use the new runtime (nodejs14.x) while creating or updating functions.
To Reproduce
Attempt to Install the stack.
Expected behavior
Installation completes correctly.
Please complete the following information about the solution:
- Version: [v1.0.2]
- Region: [eu-west-1]
Hi @mohamed-ali : Thanks for opening the issue. The bucket notifications module used in cdk library seems to refer to node.js 10x for the lambda runtime.
My initial theory is that updating the cdk version for the solution should fix it. I'll bring this up with the team and get back to you about the issue prioritization
Thanks for reviewing the issue.
It seems the switch to node12 was done in CDK 1.18.0 https://github.com/aws/aws-cdk/releases/tag/v1.18.0. I'll try that out.
Hi,
I tried cdk@1.131.0, and still has the same issue. The issue, it seems, is because one of the cdk extensions is using nodejs10 implicitly. I suspect it to be aws-s3-notifications
"BucketNotificationsHandler050a0587b7544547bf325f094a3db8347ECC3691": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Description": "AWS CloudFormation handler for \"Custom::S3BucketNotifications\" resources (@aws-cdk/aws-s3)",
"Code": {
"ZipFile": "exports.handler = (event, context) => {\n // eslint-disable-next-line @typescript-eslint/no-require-imports, import/no-extraneous-dependencies\n const s3 = new (require('aws-sdk').S3)();\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const https = require('https');\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const url = require('url');\n log(JSON.stringify(event, undefined, 2));\n const props = event.ResourceProperties;\n if (event.RequestType === 'Delete') {\n props.NotificationConfiguration = {}; // this is how you clean out notifications\n }\n const req = {\n Bucket: props.BucketName,\n NotificationConfiguration: props.NotificationConfiguration,\n };\n return s3.putBucketNotificationConfiguration(req, (err, data) => {\n log({ err, data });\n if (err) {\n return submitResponse('FAILED', err.message + `\\nMore information in CloudWatch Log Stream: ${context.logStreamName}`);\n }\n else {\n return submitResponse('SUCCESS');\n }\n });\n function log(obj) {\n console.error(event.RequestId, event.StackId, event.LogicalResourceId, obj);\n }\n // tslint:disable-next-line:max-line-length\n // adapted from https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#cfn-lambda-function-code-cfnresponsemodule\n // to allow sending an error messge as a reason.\n function submitResponse(responseStatus, reason) {\n const responseBody = JSON.stringify({\n Status: responseStatus,\n Reason: reason || 'See the details in CloudWatch Log Stream: ' + context.logStreamName,\n PhysicalResourceId: event.PhysicalResourceId || event.LogicalResourceId,\n StackId: event.StackId,\n RequestId: event.RequestId,\n LogicalResourceId: event.LogicalResourceId,\n NoEcho: false,\n });\n log({ responseBody });\n const parsedUrl = url.parse(event.ResponseURL);\n const options = {\n hostname: parsedUrl.hostname,\n port: 443,\n path: parsedUrl.path,\n method: 'PUT',\n headers: {\n 'content-type': '',\n 'content-length': responseBody.length,\n },\n };\n const request = https.request(options, (r) => {\n log({ statusCode: r.statusCode, statusMessage: r.statusMessage });\n context.done();\n });\n request.on('error', (error) => {\n log({ sendError: error });\n context.done();\n });\n request.write(responseBody);\n request.end();\n }\n};"
},
"Handler": "index.handler",
"Role": {
"Fn::GetAtt": [
"BucketNotificationsHandler050a0587b7544547bf325f094a3db834RoleB6FB88EC",
"Arn"
]
},
"Runtime": "nodejs10.x",
"Timeout": 300
},
"DependsOn": [
"BucketNotificationsHandler050a0587b7544547bf325f094a3db834RoleDefaultPolicy2CF63D36",
"BucketNotificationsHandler050a0587b7544547bf325f094a3db834RoleB6FB88EC"
],
"Metadata": {
"aws:cdk:path": "DUSStack/BucketNotificationsHandler050a0587b7544547bf325f094a3db834/Resource"
}
},
Were you able to reproduce the issue from your end?
Do you have any recommendation on how to resolve this issue?
Thanks
Alright I was able to reproduce the error.
It seems if you upgrade the aws-s3-notifications package in package.json, we should be good.
So along with upgrading all cdk packages to 1.131.0, please explicitly include aws-s3-notifications at 1.131.0
"@aws-cdk/aws-s3-notifications": "1.131.0",
That seems to fix the deployment but it'll take a few days before it merged in the repo
Let me know if that works
Note, we will need to update a couple of deployments
We have a GitHub based deployment that supports
- Dev Deploy and CICD Deploy on GitHub
- Automated deploy via AWS Solutions deployment
To integrate the fix, we can move ahead with 2 options -
- Updating a separate branch on GitHub with the fix. [ETA : 11/20/21]
Once this fix is in place, users on GitHub can checkout the fixed branch and continue with deployment - Merging the fix on main branch and updating the AWS Solutions deployment [ETA : TBD]
Once this is done, the AWS Solutions deployment and main branch should support the fix
While the above options are in place, users can try this
Note, we will need to update a couple of deployments
We have a GitHub based deployment that supports
- Dev Deploy and CICD Deploy on GitHub
- Automated deploy via AWS Solutions deployment
To integrate the fix, we can move ahead with 2 options -
-
Updating a separate branch on GitHub with the fix. [ETA : 11/20/21]
Once this fix is in place, users on GitHub can checkout the fixed branch and continue with deployment
This is completed as of 11/12/01 : Please use the cdkUpgrade branch added as part of the PR #201 -
Merging the fix on main branch and updating the AWS Solutions deployment [ETA :
TBD11/22/21]
Once this is done, the AWS Solutions deployment and main branch should support the fix
The new version (v1.0.3) is now released.
v.1.0.3 addresses the issue with the deployment. Closing out the issue. Please reopen if you still see deployment issues