lifadev / archive_aws-lambda-go

A fast and clean way to execute Go on AWS Lambda.
https://github.com/eawsy/aws-lambda-go
Apache License 2.0
699 stars 36 forks source link

Add support for including static files inside the Lambda zip file #8

Closed cristim closed 7 years ago

cristim commented 7 years ago

I know this can be achieved using jteeuwen/go-bindata, but in some cases it may make sense to read files at runtime line by line, without loading all the content into memory.

fsenart commented 7 years ago

There are several aspects to consider.

I think that this project should remain as tiny as possible to be able to replace it with a future official support from AWS, seamlessly. We currently provide the Docker image for building and packaging convenience and it is not intended to become a full featured (and idiomatic) tool. Note that I'm not saying that we should not provide such tool but that this repository may not be the appropriate place for it.

Now if we think about a durable way to address this issue, we have to consider something like .lambdaignore or .lambdakeep files. Isn't it? (btw, this is what I mean by idiomatic)

Finally, at eawsy, we consider that Lambda's functionality and therefore package should have one nano purpose. By considering the issue from this angle, we can say that one will never have more that one or two files (if any) to append to the package.

Also, to address this issue, what do you think about changing a little bit the current Docker entrypoint to allow to append any files given in the command line to the final package. Something like:

docker run --rm -v $GOPATH:/go -v $PWD:/tmp eawsy/aws-lambda-go -optX valX file1 file2 fileN
cristim commented 7 years ago

I agree with you, this should be just a stop-gap until AWS implements Go spport, hopefully that happens soon, they tend to announce this kind of things at re:invent.

I think it would be enough to have some FAQ list which explains what this project tries to do and what is out of scope, while also giving some workarounds for the missing functionality.

My use case is passing a couple of files needed at runtime: a config file and a data file used by the binary.

I think I will just start using the go-bindata library to generate go source files out of my static files, and the go build tool would treat them as source code and compile them into the binary. This shouldn't need any changes in aws-lambda-go.

fsenart commented 7 years ago

We are waiting re:Invent too, and hopefully... :)

For the FAQ, it would be great but it's a bit time consuming to write down such info. I put this in the backlog.

For now, I will close the issue, but notice that a solution as described in my previous comment is fully backward compatible with the current Docker entrypoint. Also if you encounter any problem using go-bindata do not hesitate to leave a comment and we will proceed to the modification.