Skip to content

For hacking Lambda runtime versions in CDK

License

Notifications You must be signed in to change notification settings

isotoma/cdk-lambda-runtime-hacker

Repository files navigation

cdk-lambda-runtime-hacker

npm GitHub package.json dynamic NPM

For hacking Lambda runtime versions in CDK

Note that this is definitely not safe in general. You might find that your code runs fine in the new runtime.

import { cdkLambdaRuntimeHack } from 'cdk-lambda-runtime-hacker';

...

const app = new cdk.App();

// Then attach things to app, like stacks, with constructs and Lambda functions

// Then force all uses of node10 Lambda runtimes to become node12, and
// hope that you don't get any bugs
cdkLambdaRuntimeHack(app, {
    maps: [{
        runtimeFrom: lambda.Runtime.NODEJS_10_X,
        runtimeTo: lambda.Runtime.NODEJS_12_X,
    }],
});

CDK v1 and v2

The export from the top level is for CDK v2. However, you can import an equivalent function that works with CDK v1 as follows:

import { cdkLambdaRuntimeHack } from 'cdk-lambda-runtime-hacker/cdkv1';

And, for consistency, CDK v2 is available as follows too:

import { cdkLambdaRuntimeHack } from 'cdk-lambda-runtime-hacker/cdkv2';