Does anyone know how to activate with typescript CDK? There is literally no documentation from AWS how to set it up with their Lambda SDK.
any sample code?
Here is the TypeScript sample:
import * as lambda from "@aws-cdk/aws-lambda";
import * as cdk from "@aws-cdk/core";
export class LambdaSnapStartStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const lambdaFunction = new lambda.Function(this, "lambda-function", {
functionName: "MyPrettyFunction",
runtime: lambda.Runtime.JAVA_11,
memorySize: 1024,
timeout: cdk.Duration.seconds(30),
handler: "my_lambda.lambda_handler",
code: lambda.Code.fromAsset("my_lambda.zip")
// other properties
});
// Enable SnapStart
const cfnFunction = lambdaFunction.node.defaultChild as lambda.CfnFunction;
cfnFunction.addPropertyOverride("SnapStart", { ApplyOn: "PublishedVersions" });
}
}