Skip to content

Latest commit

 

History

History
50 lines (37 loc) · 966 Bytes

File metadata and controls

50 lines (37 loc) · 966 Bytes

Create function

aws lambda create-function \
--function-name lock-and-dispatch-event \
--zip-file fileb://main.zip \
--handler main \
--runtime go1.x \
--role "arn:aws:iam::987933226201:role/lambda-basic-execution"

Test invoke

aws lambda invoke \
--function-name lock-and-dispatch-event \
--invocation-type "RequestResponse" \
response.txt

Update function

aws lambda update-function-code \
--function-name lock-and-dispatch-event \
--zip-file fileb://main.zip

Build it for AWS Lambda

It needs different build and parameters so it can be run on AWS

GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o main main.go

Zip it

zip main.zip main

Troubleshooting

Lambda path error

"errorMessage" => "fork/exec /var/task/main: exec format error", "errorType" => "PathError"}

This means your build doesn't work with AWS Lambda, please build it with the env written above