pulumi / pulumi-awsx

AWS infrastructure best practices in component form!
https://www.pulumi.com/docs/guides/crosswalk/aws/
Apache License 2.0
222 stars 104 forks source link

Simplify deploying Python and TypeScript lambdas with dependencies #1290

Open t0yv0 opened 4 months ago

t0yv0 commented 4 months ago

Hello!

Issue details

Consider simplifying deploying lambda function code with dependencies as this is non-trivial for beginners.

An existing solution in this space is the lambda-builders library. It has CLI with a JSON-RPC interface. Scope of this library: “given a folder containing function's source code, the selected build action, and path to an artifacts folder, this library will produce built artifacts in the artifacts folder.”

Possibly Pulumi could integrate with it directly to provide a component library where you could write:

const testLambda = new aws.lambda.Function("test_lambda", {
    code: new lambda_builders.Nodejs("../path/to/package.json"), // uses lambda-builders 
    name: "lambda_function_name",
    role: iamForLambda.arn,
    handler: "index.test",
    runtime: "nodejs18.x",
 });

Affected area/feature

t0yv0 commented 4 months ago

One interesting user story: https://levelup.gitconnected.com/my-journey-with-pulumi-and-the-serverless-framework-2b1398ee581a - there might be additional complications for CallbackFunction coming from closure serialization, but even if those were not fully addressed if we could guide users to a reasonable way to refactor CallbackFunctions into normal functions that could be helpful here.