import * as cdk from '@aws-cdk/core' ; import { AssetCode , LayerVersion , LayerVersionProps , CfnLayerVersion , Runtime } from '@aws-cdk/aws-lambda' ; import { FollowMode } from '@aws-cdk/assets' ; export interface LambdaLayerProps { readonly contentLocation : string ; readonly compatibleRuntimes ? : Runtime [ ] ; readonly description ? : string ; readonly license ? : string ; } export class RetainedLambdaLayerVersion extends LayerVersion { constructor ( scope , id , props ) { const lambdaVersionProps = { description : props . description , compatibleRuntimes : props . compatibleRuntimes , code : new AssetCode ( props . contentLocation , { follow : FollowMode . ALWAYS } ) , license : props . license , } ; super ( scope , id , lambdaVersionProps ) ; const layerVersion = this . node . findChild ( 'Resource' ) as CfnLayerVersion ; layerVersion . addOverride ( 'UpdateReplacePolicy' , 'Retain' ) ; } }