valheim-ecs-fargate-cdk icon indicating copy to clipboard operation
valheim-ecs-fargate-cdk copied to clipboard

serverstatus and serverstartstop API Gateway Lambda fails

Open rjaduthie opened this issue 2 years ago • 4 comments

There seems to be some slight misconfiguration for the updownstatus API. The API responds with 500 and the Lambda logs show that the handler is not found:

{
    "errorType": "Runtime.HandlerNotFound",
    "errorMessage": "index.handler is undefined or not exported",
    "stack": [
        "Runtime.HandlerNotFound: index.handler is undefined or not exported",
        "    at UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1038:15)",
        "    at async start (file:///var/runtime/index.mjs:1200:23)",
        "    at async file:///var/runtime/index.mjs:1206:1"
    ]
}

Both endpoints are affected.

I'll take a look at this, but it'll be the earliest tomorrow.

Screenshot 2023-01-18 at 22 36 33

rjaduthie avatar Jan 18 '23 22:01 rjaduthie

Wondering if it doesn't like this recent change for some reason: https://github.com/rileydakota/valheim-ecs-fargate-cdk/blob/61bf2bb3db9207cd633a02969dc45522a9319b01/resources/serverstatus.ts#L38

Although it appears to still be exported here: https://github.com/rileydakota/valheim-ecs-fargate-cdk/blob/61bf2bb3db9207cd633a02969dc45522a9319b01/resources/serverstatus.ts#L53

The original: https://github.com/rileydakota/valheim-ecs-fargate-cdk/blob/72bee852ae6dcd19b674b9daa7197f59cabd861c/resources/serverstatus.ts#L29

I should have some time to take a look tonight as well

rileydakota avatar Jan 19 '23 16:01 rileydakota

My initial tests, it looks like reverting this fixes the issue. I've still got some work to figure out how to use this API properly; it's late here, so maybe I can finish testing another day.

rjaduthie avatar Jan 19 '23 23:01 rjaduthie

OK, didn't leave this. The fix is substitute the const handler [...] lines with:

exports.handler = async (event: APIGatewayEvent, context: Context) => { 

However, the startstop endpoint doesn't seem to actually change the desire count of the Fargate task. I should probably create a new issue for this though.

rjaduthie avatar Jan 20 '23 00:01 rjaduthie

Minimal change fix in PR #33

rjaduthie avatar Jan 20 '23 00:01 rjaduthie