AWS golang Lambda using macOS
Date: February 13, 2022
Categories: Blog
If you happen to be trying to create a Lambda function in golang, you might endup getting this error:
{
"errorMessage": "fork/exec /var/task/main: exec format error",
"errorType": "PathError"
}
If that’s how you ended up in this corner of the web let me point you in the right direction. Here: https://docs.aws.amazon.com/lambda/latest/dg/golang-package.html
The problem was that I didn’t read the section “Creating a .zip file on macOS and Linux”, you have to let go know that this will run on linux:
GOOS=linux go build main.go
Once you do that, zip the executable (just the executable!) and upload it to AWS.
You are good to go now!