What options do I have if I want to redistribute a Lambda function as a CDK construct? By this, I mean a construct that someone else could use in their project that might define one or more Lambda functions.
Assuming that the CDK construct is written in Typescript, the construct itself can be packaged for use in other CDK projects written in Typescript and redistributed via npm, or it could be transpiled into other JSII-supported languages such as Python or Java and published at an appropriate module location, such as Maven Central etc.
However, how can the implementation of the Lambda be redistributed via that CDK module (i.e. the code that will be executed when the Lambda fires)?
The options I can think of are:
- Write the Lambda in a language such as JS or Python and define the Lambda inline within the CDK construct. Limited to small functions and rules out Lambdas written in other languages, such as Golang, Rust or Java.
- The publisher of the construct saves the Lambda implementation (as a zip) somewhere in S3 and have the construct point at that location. This would mean that the person publishing the module would be responsible for hosting the implementation zip and assumes that the person consuming the construct trusts what has been written in the implementation.
- What other options are available, if any?