Overwhelmed by CDK? Here’s a Simple Guide for Deploying TypeScript Lambdas
Why would you not just use the build in nodejsfunction though? No need for a seperate build step.
If you have a large CDK and lots of lambda code it is better to split it out into different packages
Especially if you’re working with multiple devs. You might want to limit access, for example a freelancer might only need to contribute to the lambda source code, not CDK.
Big thing worth noting - you shouldn’t install aws-lambda package. Better to just install the types for it.
The package itself is for running lambda locally, but it also exports a heap of really good type definitions for Lambda’s events.
However, if you build your example app the bundle size will be huge. aws-lambda has a dependency on v2 of aws-sdk - which doesn’t tree shake, and isn’t bundled on lambda runtimes for node 18/20. So your bundle size will jump by a few MB for some type definitions.
If you install just the types file you get the type definitions you know and love, and never risk accidentally importing the massive dependency.
The two packages `aws-lambda` and `@types/aws-lambda` are unrelated. The latter is part of the (DefinitelyTyped)[https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/aws-lambda\].