How to create a WebSocket API with serverless

Link to chapter — https://serverless-stack.com/examples/how-to-create-a-websocket-api-with-serverless.html

Is there a fix for this error:

Error: CloudWatch Logs role ARN must be set in account settings to enable logging (Service: AmazonApiGatewayV2; Status Code: 400; Error Code: BadRequestException; Request ID: SOME-UUID; Proxy: null)

Helper: This is a common error when configuring Access Log for WebSocket APIs. The AWS API Gateway service in your AWS account does not have permissions to the CloudWatch logs service. Follow this article to create an IAM role for logging to CloudWatch - https://aws.amazon.com/premiumsupport/knowledge-center/api-gateway-cloudwatch-logs/

The recommended link, and this one on SST both say to edit the API to add the role, but the deploy is blocked on the above error and the API cannot be created.

Is there a way to add the role and its ARN to the Stack?

Anybody solved this issue yet?

To follow up on this, when you are you all getting this error?

Not OP, but I get this error when following the documentation for setting up a websocket API

  • npm init serverless-stack --example websocket
  • cd websocket
  • npm run start

results in: mystage-websocket-my-stack failed: CloudWatch Logs role ARN must be set in account settings to enable logging (Service: AmazonApiGatewayV2; Status Code: 400; Error Code: BadRequestException; Request ID: xxxx; Proxy: null)

That’s a weird error. Maybe popover to our Sack and check if somebody’s run into it?

https://serverless-stack.com/slack

Got some help in slack, recommended solution is to just follow the instructions in the link (Turn on CloudWatch logs for API Gateway REST APIs and WebSocket APIs) and add the role manually via the aws console.

Issue OP was probably having was that API Gateway UI is stupid and you have to have an API created in ordered to access the global API Gateway settings (can create a dummy API and delete it after the deploy).

What react frontend websocket library are you supposed to use for this? I have tried with “socket.io-client”.