Hello everyone! I’m trying to deploy my golang example program to AWS Lambda via the Serverless Framework however i’m running into an issue. I’m developing on a Windows machine (Note: This issue does not apply to Mac/Linux machines… only Windows)
I’m trying to deploy a simple application like so:
Makefile
build:
dep ensure
set GOOS=linux
set GOARCH=amd64
go build -ldflags="-s -w -v" -o bin/hello hello/main.go
deploy:
@make build
sls deploy
prod-deploy:
@make build
sls deploy --stage prod
remove:
serverless remove -v
serverless.yml
service: aws-golang
provider:
name: aws
runtime: go1.x
package:
exclude:
- ./**
include:
- ./bin/**
functions:
hello:
handler: bin/hello
events:
- http:
path: hello
method: post
main.go
package main
import (
"fmt"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
)
// Handler passes request body to the response
func Handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
fmt.Println("Received body: ", request.Body)
return events.APIGatewayProxyResponse{Body: request.Body, StatusCode: 200}, nil
}
func main() {
lambda.Start(Handler)
}
After I successfully deploy the golang app to Lambda… and try to run the application it gives me:
{
“errorMessage”: “fork/exec /var/task/bin/hello: permission denied”,
“errorType”: “PathError”
}
I’ve been researching this issue and it look’s like there’s a permissions issue on Windows when it zips the files it needs to upload to S3. There is another tool that seems to package the files just fine… however I want to be able to just use Serverless.
I’ve noticed this issue in the past…however i’m revisting it since I want to be able to use Golang soon. I feel like this should be a simple fix… however nothing seems to be done about it
Can someone please give me feedback on what I could do… or how long it could take to fix this!