Closed pinzon closed 3 years ago
So I'm trying to run a go lambda function locally as a test. Base on the go1.x run image Dockerfile I made this process:
package main
import ( "context" "fmt" "os"
"github.com/aws/aws-lambda-go/lambda"
)
type MyEvent struct { Name string json:"name" }
json:"name"
func HandleRequest(ctx context.Context, name MyEvent) (string, error) { fmt.Println(os.Getenv("_LAMBDA_LOG_FD")) return fmt.Sprintf("Hello %s!", name.Name), nil }
func main() { lambda.Start(HandleRequest) }
3. Trying to run the function with aws-lambda-go `AWS_EXECUTION_ENV=AWS_Lambda_go1.x _LAMBDA_LOG_FD=9 GOPROXY=direct ./var/runtime/aws-lambda-go --debug ./function '{"name":"kevs"}'` But I'm getting this logs, and I'm not sure what to do next.
02 Jul 2021 02:14:34,916 [ERROR] (runtime_init_optional_cleanup@src/lambda/runtime.c:900 errno: Bad file descriptor) (lambda_set_log_fd(fd)) == 0 failed. 02 Jul 2021 02:14:34,916 [ERROR] (runtime_init_optional_cleanup@src/lambda/runtime.c:968 errno: Bad file descriptor) Runtime internal error 2021/07/01 21:14:34 runtime_init failed
Thank you in advance for your help.
Found out how to do it.
@pinzon this is when you share your discovery just in case.
jajaja sorry, you're right. I wrote this code with what I found inside the code of this project. The makefile explains how to use it.
So I'm trying to run a go lambda function locally as a test. Base on the go1.x run image Dockerfile I made this process:
import ( "context" "fmt" "os"
)
type MyEvent struct { Name string
json:"name"
}func HandleRequest(ctx context.Context, name MyEvent) (string, error) { fmt.Println(os.Getenv("_LAMBDA_LOG_FD")) return fmt.Sprintf("Hello %s!", name.Name), nil }
func main() { lambda.Start(HandleRequest) }
02 Jul 2021 02:14:34,916 [ERROR] (runtime_init_optional_cleanup@src/lambda/runtime.c:900 errno: Bad file descriptor) (lambda_set_log_fd(fd)) == 0 failed. 02 Jul 2021 02:14:34,916 [ERROR] (runtime_init_optional_cleanup@src/lambda/runtime.c:968 errno: Bad file descriptor) Runtime internal error 2021/07/01 21:14:34 runtime_init failed