|
1 | 1 | # AWS Lambda Deployment Package in Go<a name="lambda-go-how-to-create-deployment-package"></a>
|
2 | 2 |
|
3 |
| -To create a Lambda function you first create a Lambda function deployment package, a \.zip file consisting of your code and any dependencies\. |
| 3 | +To create a Lambda function you first create a Lambda function deployment package, a \.zip file consisting of your code (a Go executable) and any dependencies\. |
4 | 4 |
|
5 | 5 | After you create a deployment package, you may either upload it directly or upload the \.zip file first to an Amazon S3 bucket in the same AWS region where you want to create the Lambda function, and then specify the bucket name and object key name when you create the Lambda function using the console or the AWS CLI\.
|
6 | 6 |
|
7 | 7 | For Lambda functions written in Go, download the Lambda library for Go by navigating to the Go runtime directory and enter the following command: `go get github.com/aws/aws-lambda-go/lambda`
|
8 | 8 |
|
9 |
| -Then use following command to build, package and deploy a Go Lambda function via the CLI\. Note that your *function\-name *must match the name of your *Lambda handler* name\. |
| 9 | +Then use following command to build, package and deploy a Go Lambda function via the CLI\. Note that the *handler* parameter must match the name of the executable containing your Lambda handler\. |
10 | 10 |
|
11 | 11 | ```
|
12 | 12 | GOOS=linux go build lambda_handler.go
|
13 | 13 | zip handler.zip ./lambda_handler
|
14 | 14 | # --handler is the path to the executable inside the .zip
|
15 | 15 | aws lambda create-function \
|
16 | 16 | --region region \
|
17 |
| - --function-name lambda-handler \ |
| 17 | + --function-name function-name \ |
18 | 18 | --memory 128 \
|
19 | 19 | --role arn:aws:iam::account-id:role/execution_role \
|
20 | 20 | --runtime go1.x \
|
21 | 21 | --zip-file fileb://path-to-your-zip-file/handler.zip \
|
22 |
| - --handler lambda-handler |
| 22 | + --handler lambda-handler-executable |
23 | 23 | ```
|
24 | 24 |
|
25 | 25 | **Note**
|
@@ -54,4 +54,4 @@ In Powershell, run the following:
|
54 | 54 | $env:GOOS = "linux"
|
55 | 55 | go build -o main main.go
|
56 | 56 | ~\Go\Bin\build-lambda-zip.exe -o main.zip main
|
57 |
| -``` |
| 57 | +``` |
0 commit comments