AWS Nodejs14.x is no longer supported

Suppose you run into this exception while deploying your infrastructure using CDK v1 code to AWS:

The runtime parameter of nodejs14.x is no longer supported for creating or updating AWS Lambda functions. We recommend you use the new runtime (nodejs20.x) while creating or updating functions.

And you think: wait, I don’t have any lambdas, why do I keep receiving this?

The thing is that CDK v1 implicitly creates lambda functions to support some functionality. For example, when you create S3 bucket this way:

const bucket = new Bucket(this, 'RunCommandBucket', {
autoDeleteObjects: true,
    ...
});

CDK v1 implicitly creates Lambda function with hardcoded runtime of NODEJS_14_X. Have a look at the sources here: https://github.com/aws/aws-cdk/blob/9752ed225c82982d8b443f7c6a47f47979458217/packages/%40aws-cdk/aws-s3/lib/bucket.ts#L2132.

Another example is when you create a Dynamo table:

const dynamoTable = new Table(this, 'MyDynamoDBTable', {
    ...
});
  1. CDK v1 main DynamoDB construction class creates new ReplicaProvider here https://github.com/aws/aws-cdk/blob/9752ed225c82982d8b443f7c6a47f47979458217/packages/%40aws-cdk/aws-dynamodb/lib/table.ts#L1574.
  2. ReplicaProvider creates even two lambdas with hardcoded NODEJS_14_X runtime version: https://github.com/aws/aws-cdk/blob/9752ed225c82982d8b443f7c6a47f47979458217/packages/%40aws-cdk/aws-dynamodb/lib/replica-provider.ts#L57.

So the possible solutions may be:

  1. Upgrade to CDK v2. Select the latest version, since not all CDK v2 versions have this fix.
  2. Move infra to terraform or something.
  3. Consider leveraging some dark JS magic outside of Hogwarts to replace these constants (kind of runtime-monkey-patching); for sure, this is risky and unstable approach.
  4. Remove all code from your CDK v1 that implicitly creates lambda functions (again, it’s at least S3 buckets and Dynamo tables creation).

That’s all.

Telegram channel

If you still have any questions, feel free to ask me in the comments under this article or write me at promark33@gmail.com.

If I saved your day, you can support me 🤝

Leave a Reply

Your email address will not be published. Required fields are marked *