georgeboot / laravel-echo-api-gateway

Use Laravel Echo with API Gateway Websockets. Works with Bref.sh and Laravel Vapor.
MIT License
99 stars 21 forks source link

What code should be in the AWS Lambda? #17

Closed ondrejehrlich closed 1 year ago

ondrejehrlich commented 2 years ago

I struggle to set up this with Laravel Vapor deployment. I've created API gateway (websockets), and DynamoDB table as described. I also set the right permissions to laravel-vapor-role. But when I connect to the websockets API from the frontend or terminal, the connectionID is not created in the DynamoDB and when I insert the connectionID by hand into the DynamoDB the message is still not sent to the client. What code should be there in the AWS Lambda to make this happen?

georgeboot commented 2 years ago

Create a new Websocket API. Enter a name and leave the route selection expression to what it is. Add a $disconnect and $default. Set both integrations to Lambda and select your CLI lambda from the list. Set the name of the stage to what you desire and create the API. Once created, write down the ID, as we'll need it later.

Your Vapor setup should generate 3 Lambda functions: http (your-app), artisan (your-app-artisan) and queue (your-app-queue). The artisan one is the one you should link.

ondrejehrlich commented 1 year ago

Thank you. I'm closing the issue.