-
-
Notifications
You must be signed in to change notification settings - Fork 82
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 packaging of static files alongside binary #41
Comments
That's a good point. I've deferred in adding features until they are needed or asked for. I'll look into this |
I was under the impression that this was already supported. How would I add this capability myself for my current serverless project? |
An alternative solution to the static file packaging problem is to use AWS Lambda Layers. Example:
In your serverless.yml insert: layers:
mydata:
path: static
description: My static json data
In your function you can put the dependency on your layer as a title cased reference: functions:
myfunction:
handler: #...
layers:
- {Ref: MydataLambdaLayer}
# ..... You can now access your files as if they are located in the "/opt" folder of your lambda, e.g.: let file = File::open("/opt/foo.json")?; This solution is quite useful especially when you want to share your static data between different lambdas. |
I think we could use the "include" attribute of a function and "add" the files to the zip after the build in the container succeeded. |
Adding another use case, which requires having a certificate file to communicate with a certain server. |
I just wanted to point out that the workaround of @nickspell doesnt work for my use case which is opening a sqlite db. For some reason I'm getting a |
I think the most appropriate way to approach this is the suggestion original mentioned. Use the built in |
@softprops Could you tell me if it would be possible to use a rust program that has an |
This looks a bit involved but possibly doable. A lambda layer might be a useful approach here. Heres an example from the python world of setting up a layer https://www.bigendiandata.com/2019-04-15-OpenCV_AWS_Lambda/ I'm not familiar with the opencv project enough myself to know why there might not be an off the shelf layer available https://github.com/mthenw/awesome-layers |
Thanks for the informative and helpful reply @softprops |
Without more expertise in opencv I cant gaurantee this will work but to answer the question about using layers to package host dependencies, that's almost the sole use of layers https://aws.amazon.com/blogs/aws/new-for-aws-lambda-use-any-programming-language-and-share-common-components/ That said this is likely an easier case for interpreted languages im not sure if you can package and dynamically link via env var with rust. I glanced through the opencv docs and there was some suggestions that you could |
Thanks a lot @softprops |
💡 Feature description
It would be nice if it was possible to use the
include
andexclude
package configuration inserverless.yml
to choose other files to bundle with the bootstrap binary. For example to include a.env
file that is then read by the dotenv crate at runtime.I am sure that there are other use cases for including files other than the binary but that is the one that sprang to mind.
The text was updated successfully, but these errors were encountered: