Description
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
Activity
bmoffatt commentedon Apr 6, 2023
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.
Yeah
go1.x
doesn't need the bootstrap symlink. It's for use with theprovided
andprovided.al2
runtimes.js10x commentedon 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.bmoffatt commentedon 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 commentedon Apr 8, 2023
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 commentedon Apr 8, 2023
I've referenced the
-ldflags
feedback in #498 - so that this thread can stay focused onbuild-lambda-zip