Home > OS >  Deploy additional files with Node Lambda Function AWS CDK
Deploy additional files with Node Lambda Function AWS CDK

Time:09-03

I'm trying to deploy my AWS lambda function using the CDK, but I want to bundle other files in the lambda as well (JSON files). How do I go about this other than using CommandHooks and copying the files myself? For reference, I'm not importing the file. A library I'm using is importing it and requires the path to the file as a string. I've tried using the loader option, but that changes the name of the file and breaks the path that the library was given.

For reference, this works: https://github.com/aws/aws-cdk/issues/11468

but I'd prefer having to do that for every lambda.

CodePudding user response:

If the functions all share the same files, then you might prefer to create a Lambda layer to copy the files over.

If each function requires different files however, then the bundling option is just as easy. It's IAC after all, so you can just create a helper function to make it a bit less repetitive.

  • Related