I was trying to create an s3:put
event on one of the existing lambda functions and S3 buckets using serverless.
But was getting this error from AWS CloudFormation even though the lambda function doesn’t use nodejs12.x. One note – the lambda is old, so it is using python3.7, which might be EOL soon, but we can’t upgrade the version just yet due to dependencies on python3.7
Resource handler returned 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. (Service: Lambda, Status Code: 400,
Request ID:)
On CloudFormation, the failure is on this resource creation CustomDashresourceDashexistingDashs3LambdaFunction
with the same error as above.
This is the serverless code I was using –
provider:
name: aws
runtime: python3.7
.....
functions:
antivirus-scan:
handler: src/scan.lambda_handler
awsKmsKeyArn: ${opt:kms_arn, ""}
role: antivirusFunctionRole
memorySize: 2048
timeout: 300 # 5mins
events:
- s3:
bucket: ${self:custom.antivirus_files_bucket}
event: s3:ObjectCreated:*
existing: true
I tried removing the event and recreating it, which doesn’t work. The S3 bucket is created outside of the CloudFormation template.
2
Answers
I found the cause, serverless v2 is deprecated https://github.com/serverless/serverless/issues/11400.
Need to upgrade to v3.
I am facing similar issue using runtime python3.9.
ServerlessError: An error occurred: CustomDashresourceDashexistingDashs3LambdaFunction – Resource handler returned 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.