skip to Main Content

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


  1. Chosen as BEST ANSWER

    I found the cause, serverless v2 is deprecated https://github.com/serverless/serverless/issues/11400.

    Need to upgrade to v3.


  2. 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.

    provider:
      name: aws
      runtime: python3.9
    ....
    functions:
      audienceSplitter:
        handler: app/handler.trackMyOrder
        name: trackMyOrder
        description: 'Splits the audience into control and test groups'
        tracing: Active
        timeout: 900 # lambda function Maximum timeout
        events:
          - s3:
              bucket: track-my-order
              event: s3:ObjectCreated:*
              rules:
                - suffix: .jpg
              existing: true
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search