-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow single files as Lambda code assets #4428
Comments
Hey @nakedible, Thank you for submitting a request! This sounds like a reasonable feature to implement. Changing the functionality of If you want to implement this, please feel free to put in a PR. Otherwise, someone will update this issue when any changes are made. |
Since #4473 has landed, which has support for richer code: lambda.Code.fromAsset(".", {exclude: ["**", "!index.py"]}), You can consider adding this example somewhere if you wish, or just closing this outright. |
This is very cool! Thanks. Maybe we can add a little sugar that will make this easier to use. |
I like the idea of deprecating |
Closing in favour of #4776 |
Currently, a Lambda code asset can either be a directory that is zipped and provided through the asset mechanism, or inline code that is limited to 4 kilobytes and supports only Python and Node.js. Inline code cannot be directly specified from a file, but it must first be read as string in the language runtime used, without the help of CDK. It would be nice to be able to specify a single file, that would automatically get added to a zip and be provided through the asset mechanism.
Use Case
Many Lambda functions are more complex than 4096 bytes, but still exist in a single file without any dependencies. It would be very convenient to be able to specify these as assets directly, instead of having to create multiple directories containing only that single file. Especially with layers, single file functions are very common.
Proposed Solution
Either allow the normal
fromAsset
function to automatically zip single files:Or provide a separate function, such as
fromSingleAsset
orfromAssetZip
. The current magic of directories being automatically zipped and single files being automatically used without transformation is a bit confusing. Could also consider creatingfromAssetDir
,fromAssetFile
andfromAssetZip
to make it very explicit what the intent is.Other
This is a 🚀 Feature Request
The text was updated successfully, but these errors were encountered: