You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28-4
Original file line number
Diff line number
Diff line change
@@ -43,16 +43,26 @@ func main() {
43
43
44
44
# Building your function
45
45
46
-
Preparing a binary to deploy to AWS Lambda requires that it is compiled for Linux and placed into a .zip file.
46
+
Preparing a binary to deploy to AWS Lambda requires that it is compiled for Linux and placed into a .zip file. When using the `provided`, `provided.al2`, or `provided.al2023` runtime, the executable within the .zip file should be named `bootstrap`. Lambda's default architecture is `x86_64`, so when cross compiling from a non-x86 environment, the executable should be built with `GOARCH=amd64`. Likewise, if the Lambda function will be [configured to use ARM](https://docs.aws.amazon.com/lambda/latest/dg/foundation-arch.html), the executable should built with `GOARCH=arm64`.
47
47
48
-
## For developers on Linux and macOS
49
48
```shell
50
-
# Remember to build your handler executable for Linux!
51
-
# When using the `provided.al2` runtime, the handler executable should be named `bootstrap`
52
49
GOOS=linux GOARCH=amd64 go build -o bootstrap main.go
53
50
zip lambda-handler.zip bootstrap
54
51
```
55
52
53
+
## For developers on Linux
54
+
55
+
On Linux, the Go compiler's default behavior is to link the output executable to the system libc for some standard library functionality (for example, DNS lookups). If the build environment is using a Linux distribution with a GNU libc version newer than the deployment environment, the application when deployed to Lambda may fail with an error like ``/lib64/libc.so.6: version `GLIBC_X.YZ' not found``.
56
+
57
+
Most Go applications do not require linking to the system libc. This behavior can be disabled by using the `CGO_ENABLED` environment variable.
58
+
59
+
```
60
+
CGO_ENABLED=0 go build -o bootstrap main.go
61
+
zip lambda-handler.zip bootstrap
62
+
```
63
+
64
+
See [Using CGO](#using-cgo)
65
+
56
66
## For developers on Windows
57
67
58
68
Windows developers may have trouble producing a zip file that marks the binary as executable on Linux. To create a .zip that will work on AWS Lambda, the `build-lambda-zip` tool may be helpful.
For applications that require CGO, the build environment must be using a GNU libc version installed compatible with the target Lambda runtime. Otherwise, execution may fail with errors like ``/lib64/libc.so.6: version `GLIBC_X.YZ' not found``.
98
+
99
+
| Lambda runtime | GLIBC version
100
+
| ----- | ---
101
+
| `provided.al2023` | 2.34
102
+
| `provided.al2` | 2.26
103
+
| `provided` and `go1.x` | 2.17
104
+
105
+
106
+
Alternatively, Lambda supports container images as a deployment package alternative to .zip files. For more information, refer to the official documentation for [working with with container images](https://docs.aws.amazon.com/lambda/latest/dg/images-create.html).
107
+
84
108
# Deploying your functions
85
109
86
110
To deploy your function, refer to the official documentation for [deploying using the AWS CLI, AWS Cloudformation, and AWS SAM](https://docs.aws.amazon.com/lambda/latest/dg/deploying-lambda-apps.html).
0 commit comments