I am trying to do basic db connection in AWS Lambda with Go, and for some reason, it got stuck at db.prepare() and no log is presented in cloudwatch.
func Handler(request Request) (Response, error) {
db, err := sql.Open("mysql", dbUsername+":"+dbPassword+"@tcp("+dbURL+":"+dbPort+")/"+dbName)
if err != nil {
log.Fatal(err)
}
defer db.Close()
stmt, err := db.Prepare("SELECT id, password FROM package_passwords WHERE password = ?")
return Response{
Message: "rows",
Ok: false,
}, nil
}
weird thing is that the code above stuck at least more than 5 second in AWS Lambda while it works fine in plain go run/ go build.