Skip to content

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

Open
@js10x

Description

@js10x

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

bmoffatt commented on Apr 6, 2023

@bmoffatt
Collaborator

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

js10x commented on Apr 8, 2023

@js10x
Author

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

bmoffatt commented on Apr 8, 2023

@bmoffatt
Collaborator

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

bmoffatt commented on Apr 8, 2023

@bmoffatt
Collaborator

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

bmoffatt commented on Apr 8, 2023

@bmoffatt
Collaborator

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @bmoffatt@js10x

        Issue actions

          Question and Concerns Around build-lambda-zip Utility - Seems to be unnecessary · Issue #493 · aws/aws-lambda-go