Skip to content
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

Question and Concerns Around build-lambda-zip Utility - Seems to be unnecessary #493

Open
js10x opened this issue Apr 3, 2023 · 5 comments

Comments

@js10x
Copy link

js10x commented Apr 3, 2023

Hi there,

I'm curious to know why AWS is recommending this build tool when creating deployment packages for Lambdas written in Go.
https://github.com/aws/aws-lambda-go/blob/main/cmd/build-lambda-zip/main.go

The current readme shows that the bootstrap file it creates is specifically only designed to be used with the al.2 runtime, however the AWS docs state the al.2 runtime isn't available for use with Go at all.
https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html?icmpid=docs_lambda_help

Also, please add the necessary flags to the build command in the "build-lambda-zip" utility to remove the debug symbols from the binary, preventing the binary from being unnecessarily large.
GOOS=linux GOARCH=amd64 go build -ldflags=-w -o main main.go
zip my-deployment-package.zip main

@bmoffatt
Copy link
Collaborator

bmoffatt commented Apr 6, 2023

I'm curious to know why AWS is recommending this build tool when creating deployment packages for Lambdas written in Go.

It's to help developers on Windows who aren't also using something like Docker or WSL. Those using using Linux or macOS don't need it.

The current readme shows that the bootstrap file it creates is specifically only designed to be used with the al.2 runtime, however the AWS docs state the al.2 runtime isn't available for use with Go at all.

Yeah go1.x doesn't need the bootstrap symlink. It's for use with the provided and provided.al2 runtimes.

@js10x
Copy link
Author

js10x commented Apr 8, 2023

Appreciate the response, but I've not needed it at all and all I use is Windows haha. After compiling my lambda with the exact same command above:
$Env:GOOS="linux" $Env:GOARCH="amd64" go build -ldflags=-w -o main "main.go"

I just right click the compiled binary and use the builtin Windows "Send to Compressed" available in the standard Windows GUI, and that's it. Then upload the zip to the lambda console. Using the -ldflags=-w flags to remove the debug symbols cuts the size of the binary in half too, seems strange that AWS isn't recommending this as well. Just hoping to share some user feedback from the perspective of someone who is using lambda often, entirely from Windows. Up until I deploy the compiled files to the AWS console, that is of course.

image

@bmoffatt
Copy link
Collaborator

bmoffatt commented Apr 8, 2023

Nice! It's been a long time since #13, so something must have changed. I'll forward this on to the service team to confirm. It'd be nice to be able to simplify the documentation and deprecate the build-lambda-zip tool if it's no longer helpful.

@bmoffatt
Copy link
Collaborator

bmoffatt commented Apr 8, 2023

Using the -ldflags=-w flags to remove the debug symbols cuts the size of the binary in half too, seems strange that AWS isn't recommending this as well.

With any non-default build flags, there may be some tradeoff to understand and incorporate into any documentation. Dropping the debug symbols does seem risk free though.

@bmoffatt
Copy link
Collaborator

bmoffatt commented Apr 8, 2023

I've referenced the -ldflags feedback in #498 - so that this thread can stay focused on build-lambda-zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants