Doing some lambdas in typescript and deploying etc via cdk. All works fine however I am using:
code: lambda.Code.asset('lambdas'),
Where the local dir is lambdas. However this deploys the .js, .ts and .d.ts files within and I am wondering if there was anyway to say something like:
code: lambda.Code.asset('lambdas/*.js'),
And just deploy the javascript files for a smaller deploy etc.
I thought about using the outDir in the tsconfig file but that would also apply to the cdk stack.ts so that won't work.
So any ideas how I can just deploy js files from a ts project?
The key is use fromAsset since asset is deprecated.

A bit background about fromAssest:
Behind the scenes, CDK uses the bootstrap stack which creates new Amazon S3.
fromAssest Loads the function code from a local disk asset, the directory will be zip archived and then uploaded to bootstrap S3 bucket, then the exact location of the S3 objects will be passed when the stack is deployed.
In order to exclude files use AssetOptions - exclude. fix(assets): support exceptions to exclude patterns #4473.

Usage:
code: lambda.Code.fromAsset(".", {exclude: ['*.ts']})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With