Closed Jimbo4350 closed 4 years ago
Can you please share your serverless.yml
?
@koterpillar
org: jimbo4350
app: minimal-example-rds
service: serverless-minimal-example-rds
provider:
name: aws
runtime: haskell
region: ap-southeast-2
timeout: 100
functions:
apigw:
handler: serverless-haskell-example.api-exe
events:
- http:
path: item/test
method: get
plugins:
- serverless-haskell
- serverless-offline
If I rename serverless-haskell-example.api-exe
to serverless-haskell-example.apigw
(and make the corresponding change in the .cabal
file, the lambda function then times out on AWS but still works locally (serverless offline start
)
I don't see anything wrong with this file; perhaps you can upload a minimal project demonstrating this behaviour somewhere?
Alexey
sls package
there I get a message about serverless-haskell
version mismatch.Error: ENOENT: no such file or directory, copyfile '/.../simple-serverless-servant/.stack-work/install/.../8.4.3/bin/api-exe' -> '/.../simple-serverless-servant/api-exe'
The reason for this is in serverless.yml
, the handler must match the built executable, the function name can be arbitrary (it will be used in AWS). In your example:
functions:
apigw: # this is just for AWS
handler: serverless-haskell-example.api-exe # this must match `package.yaml`
After changing handler
to handler: serverless-haskell-example.apigw
, I was able to package the application without errors, see https://github.com/koterpillar/simple-serverless-servant.
If you're still having problems, please attach the output of running:
stack --version
npm --version
npm ci
`npm bin`/sls package
@koterpillar Thank you. However I am still having issues. I have tested the connectivity to my aws db in ghci as follows:
*Main Database Lib ServantShim> allItems
[Item {_itemId = 1},Item {_itemId = 2}]
However deploying my lambda function and testing the endpoints I get:
{"message": "Endpoint request timed out"}
Does it mean the executable is deployed to AWS and starts correctly there?
What is producing the "Endpoint request timed out" message?
So I have tested my lambda function locally with serverless-offline
with the following commands:
sls offline start
Serverless: Building handler apigw with Stack...
Serverless: Starting Offline: dev/ap-southeast-2.
Serverless: Routes for apigw:
Serverless: GET /item/test
Serverless: POST /{apiVersion}/functions/serverless-minimal-example-final-dev-apigw/invocations
Serverless: Offline [HTTP] listening on http://localhost:3000
Serverless: Enter "rp" to replay the last request
Serverless: GET /item/test (λ: apigw)
I navigate to localhost:3000
as see the following:
{"statusCode":404,"error":"Serverless-offline: route not found.","currentRoute":"get - /","existingRoutes":["get - /item/test","post - /{apiVersion}/functions/serverless-minimal-example-final-dev-apigw/invocations"]}
I then navigate to: http://localhost:3000/item/test
which responds with my test data in my aws db: [{"_itemId":1},{"_itemId":2}]
Does it mean the executable is deployed to AWS and starts correctly there?
I deployed the executable to aws then I navigate to the API Gateway endpoint
What is producing the "Endpoint request timed out" message?
My browser when I navigate to the endpoint
Look into the CloudWatch logs (or use sls logs
) to see what's happening on AWS.
Just lists timeouts:
2019-11-02T00:17:01.797Z 7f3ea16b-5d9f-4565-ba94-17037bc51f9a Task timed out after 100.06 seconds
Do you mind adding a logging statement to the start of your main function to see if it's executed then?
@koterpillar I added a logging statement and it appeared in my logs. I think I have found the issue, it may be due to my usage of beam-core
. I'll follow up in a bit.
@koterpillar False lead :man_shrugging:
So it seems like the function is deployed correctly, and you have logs to debug it further.
@koterpillar found this in the logs: ./apigw: /lib64/libm.so.6: version GLIBC_2.27 not found (required by ./apigw)
That's interesting, would you mind opening a new issue with that, for better tracking?
I have written a simple
servant
server and converted it into a lambda function that queries aMySQL
db in amazon RDS. I can get it to work locally withserverless offline start
however when I deploy it (serverless deploy
) I get the following error in my dashboard when trying to access my simple test endpoint.