import * as crypto from 'crypto' ; import * as fs from 'fs' ; import * as path from 'path' ; import * as lambda from '@aws-cdk/aws-lambda' ; import { Construct } from '@aws-cdk/core' ; /**
 * An AWS Lambda layer that includes `kubectl` and `helm`.
 */ export class KubectlLayer extends lambda . LayerVersion { constructor ( scope , id ) { super ( scope , id , { code : lambda . Code . fromAsset ( path . join ( __dirname , 'layer.zip' ) , { assetHash : hashFile ( path . join ( __dirname , 'Dockerfile' ) ) , } ) , description : 'custom layer with /opt/kubectl/kubectl and /opt/helm/helm' , } ) ; } } function hashFile ( fileName ) { return crypto . createHash ( 'sha256' ) . update ( fs . readFileSync ( fileName ) ) . digest ( 'hex' ) ; }