Project created to test the Travis ci CI/CD process.
Preparing a binary to deploy to AWS Lambda requires that it is compiled for Linux and placed into a .zip file.
# Remember to build your handler executable for Linux!
GOOS=linux GOARCH=amd64 go build -o main lambda/main.go
zip main.zip main
Windows developers may have trouble producing a zip file that marks the binary as exectuable on Linux. To create a .zip that will work on AWS Lambda, the build-lambda-zip
tool may be helpful.
Get the tool
go.exe get -u github.com/aws/aws-lambda-go/cmd/build-lambda-zip
Use the tool from your GOPATH
. If you have a default installation of Go, the tool will be in %USERPROFILE%\Go\bin
.
in cmd.exe:
set GOOS=linux
set GOARCH=amd64
go build -o main lambda/main.go
%USERPROFILE%\Go\bin\build-lambda-zip.exe -o main.zip main
in Powershell:
$env:GOOS = "linux"
$env:GOARCH = "amd64"
go build -o main lambda/main.go
~\Go\Bin\build-lambda-zip.exe -o main.zip main
To deploy your function, refer to the offical documentation for deploying using the AWS CLI, AWS Cloudformation, and AWS SAM.