How to Deploy a Go App to AWS Lambda

Web
Deploy a Go app to AWS Lambda by compiling a static binary, zipping it, and uploading it as a deployment package.

You deploy a Go app to AWS Lambda by compiling it as a static binary, packaging it into a ZIP file, and uploading it via the AWS CLI or Console.

  1. Compile your Go application as a static binary for Linux ARM64 architecture.
GOOS=linux GOARCH=arm64 go build -o main main.go
  1. Create a ZIP archive containing the binary named main.
zip function.zip main
  1. Create a new Lambda function and upload the ZIP file as the deployment package.
aws lambda create-function --function-name my-go-function --runtime provided.al2 --role arn:aws:iam::123456789012:role/lambda-execution-role --handler main --zip-file fileb://function.zip

Note: Replace the IAM role ARN with your actual execution role ARN.