From 57f8d2e49b4029bcbc97a17f99f44352f16d5a41 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Thu, 5 Nov 2026 20:05:48 +0100 Subject: [PATCH 1/7] Document WebSockets with Laravel Broadcasting Laravel Echo and broadcasting now work on API Gateway with bref/laravel-websockets. --- docs/index.mdx | 4 +- docs/laravel/_meta.js | 1 + docs/laravel/migrating-from-vapor.mdx | 2 + docs/laravel/websockets.mdx | 229 ++++++++++++++++++++++ docs/use-cases/websockets.mdx | 4 + website/src/components/home/use-cases.jsx | 2 +- 6 files changed, 239 insertions(+), 3 deletions(-) create mode 100644 docs/laravel/websockets.mdx diff --git a/docs/index.mdx b/docs/index.mdx index 21dffd4a5..b97c1ab1b 100644 --- a/docs/index.mdx +++ b/docs/index.mdx @@ -100,7 +100,7 @@ There are still a few serverless-specific constraints to be aware of: For queue workers, this is actually great: SQS and Lambda integrate natively so that we don't have to run workers (or even think about them). Bref does the rest of the job to integrate natively with Laravel Queues or Symfony Messenger. More on this in the rest of the Bref documentation. - For websocket servers, this means we cannot run servers like Ratchet or Laravel Reverb on Lambda. It is possible to run this on the side in an AWS EC2 server, or in a container in ECS, but this is extra setup. An alternative is to use the native API Gateway WebSocket feature, see the [WebSockets guide](/docs/use-cases/websockets.mdx). + For websocket servers, this means we cannot run servers like Ratchet or Laravel Reverb on Lambda. It is possible to run this on the side in an AWS EC2 server, or in a container in ECS, but this is extra setup. An alternative is to use the native API Gateway WebSocket feature, see the [WebSockets guide](/docs/use-cases/websockets.mdx). In Laravel, [Laravel Echo and broadcasting work on API Gateway](/docs/laravel/websockets.mdx). - AWS Lambda has a maximum execution time limit of 15 minutes *per invocation*. @@ -266,7 +266,7 @@ This matrix will be updated as Bref and AWS services evolve over time. - **Websockets** - It is possible to integrate PHP applications with API Gateway WebSocket, see the [WebSockets guide](/docs/use-cases/websockets.mdx). However, there is currently no native integration with Laravel Echo. + It is possible to integrate PHP applications with API Gateway WebSocket, see the [WebSockets guide](/docs/use-cases/websockets.mdx). Laravel applications can [use Laravel Echo and broadcasting](/docs/laravel/websockets.mdx). - **Real-time applications** diff --git a/docs/laravel/_meta.js b/docs/laravel/_meta.js index 441be3feb..98e20e156 100644 --- a/docs/laravel/_meta.js +++ b/docs/laravel/_meta.js @@ -5,5 +5,6 @@ export default { 'file-storage': '', queues: 'Laravel Queues', octane: 'Laravel Octane', + websockets: 'WebSockets', passport: 'Laravel Passport', }; diff --git a/docs/laravel/migrating-from-vapor.mdx b/docs/laravel/migrating-from-vapor.mdx index 1405fbe99..2c352f37d 100644 --- a/docs/laravel/migrating-from-vapor.mdx +++ b/docs/laravel/migrating-from-vapor.mdx @@ -35,6 +35,8 @@ The recommended strategy is to **keep the long-lived infrastructure and migrate - **Keep**: the database (RDS or Aurora), the Redis cache (ElastiCache), the S3 storage bucket, the network (VPC and NAT gateway), the domain and its HTTPS certificate. Vapor created these resources in your AWS account and they will continue to work without Vapor. - **Recreate with Bref**: the Lambda functions, the HTTP layer (API Gateway and CloudFront), the SQS queues and the scheduler. These are cheap, stateless and quick to recreate. +If you use Pusher or Ably for broadcasting, keep them: they work the same with Bref. To replace them with API Gateway, see [WebSockets with Laravel Broadcasting](/docs/laravel/websockets.mdx). + The migration then happens without downtime (except in one case, see [Domain and DNS switch](#domain-and-dns-switch)): 1. Deploy the application with Bref next to the Vapor environment, connected to the same database, cache and bucket, without the scheduler. diff --git a/docs/laravel/websockets.mdx b/docs/laravel/websockets.mdx new file mode 100644 index 000000000..22d996e7e --- /dev/null +++ b/docs/laravel/websockets.mdx @@ -0,0 +1,229 @@ +--- +description: "Use Laravel broadcasting and Laravel Echo with WebSockets on AWS Lambda, without running a Reverb server." +--- + +import { Tabs } from 'nextra/components'; + +# WebSockets with Laravel Broadcasting + +[Laravel Reverb](https://laravel.com/docs/reverb) cannot run on AWS Lambda, because it is a long-running process. With the [`bref/laravel-websockets`](https://github.com/brefphp/laravel-websockets) package, API Gateway holds the WebSocket connections instead, and there is no server to run. + +Laravel 12 or later is required. Broadcasting then works as described in [the Laravel documentation](https://laravel.com/docs/broadcasting): `ShouldBroadcast` events, `routes/channels.php`, and Laravel Echo with private channels, presence channels and client events (whispers). + +## Installation + +```bash +composer require bref/laravel-websockets +npm install laravel-echo pusher-js +``` + +### Enable broadcasting + +Declare the channels file in `bootstrap/app.php`: + +```php filename="bootstrap/app.php" +->withRouting( + web: __DIR__.'/../routes/web.php', + channels: __DIR__.'/../routes/channels.php', + // ... +) +``` + +Then create `routes/channels.php` as described in [the Laravel documentation](https://laravel.com/docs/broadcasting#defining-authorization-callbacks). + +Do not run `php artisan install:broadcasting`: it requires choosing one of Laravel's drivers. + +### Create the WebSocket API + +Add this to `serverless.yml`: + +```yml filename="serverless.yml" +provider: + # ... + environment: + # ... + BROADCAST_CONNECTION: api-gateway + BREF_WEBSOCKET_API_ID: !Ref WebsocketsApi + BREF_WEBSOCKET_STAGE: ${sls:stage} + iam: + role: + statements: + - Effect: Allow + Action: execute-api:ManageConnections + Resource: !Sub 'arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${WebsocketsApi}/*' + - Effect: Allow + Action: lambda:InvokeFunction + Resource: !Sub 'arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${self:service}-${sls:stage}-websocket' + +functions: + # ... + websocket: + handler: Bref\LaravelWebsockets\Handler + runtime: php-84 + timeout: 28 + events: + - websocket: $connect + - websocket: $disconnect + - websocket: $default +``` + +If your application runs in a VPC, give this function the same `vpc` configuration as your other functions. Publishing events requires internet access, for example through a NAT Gateway. + +### Store subscriptions in the database or DynamoDB + +The application stores which connection listens to which channel, in your database by default: + +| | Database (default) | DynamoDB | +|---|---|---| +| **Use it for** | Applications with a database and little traffic, back offices, preview environments | Many connections, frequent reconnections, or no database | +| **Setup** | Run `php artisan migrate` | Add a table and permissions to `serverless.yml` | +| **Cost** | Nothing more | Less than $3 per month for 1000 connections | +| **Time per operation** | 3 to 4 ms | 3 to 4 ms | +| **First operation of a request** | 12 to 29 ms | 34 to 47 ms | +| **Reconnection bursts** | Load your database, with one SQL connection per concurrent Lambda | No impact on your database | + +If your database pauses when idle (like Aurora Serverless), note that each browser tab left open writes to it every 2 hours, which keeps it awake. + +To use DynamoDB: + +```yml filename="serverless.yml" +provider: + # ... + environment: + # ... + BREF_WEBSOCKET_STORE: dynamodb + BREF_WEBSOCKET_DYNAMODB_TABLE: !Ref WebsocketSubscriptions + iam: + role: + statements: + # ... + - Effect: Allow + Action: [dynamodb:Query, dynamodb:GetItem, dynamodb:PutItem, dynamodb:DeleteItem] + Resource: + - !GetAtt WebsocketSubscriptions.Arn + - !Sub '${WebsocketSubscriptions.Arn}/index/*' + +resources: + Resources: + WebsocketSubscriptions: + Type: AWS::DynamoDB::Table + Properties: + BillingMode: PAY_PER_REQUEST + AttributeDefinitions: + - { AttributeName: channel, AttributeType: S } + - { AttributeName: connectionId, AttributeType: S } + KeySchema: + - { AttributeName: channel, KeyType: HASH } + - { AttributeName: connectionId, KeyType: RANGE } + GlobalSecondaryIndexes: + - IndexName: by-connection + KeySchema: + - { AttributeName: connectionId, KeyType: HASH } + Projection: { ProjectionType: ALL } + TimeToLiveSpecification: + AttributeName: expiresAt + Enabled: true +``` + +### Connect Laravel Echo + +Each environment has its own WebSocket API, so give its address to the frontend at runtime, in your layout: + +```blade +@if (config('bref-websockets.api_id')) + + +@endif +``` + +Then configure Echo: + +```js filename="resources/js/echo.js" +import Echo from 'laravel-echo'; +import Pusher from 'pusher-js'; + +const host = document.querySelector('meta[name="websocket-host"]')?.content; +const stage = document.querySelector('meta[name="websocket-stage"]')?.content; + +if (host) { + window.Pusher = Pusher; + + window.Echo = new Echo({ + broadcaster: 'reverb', + key: 'bref', // Any value + wsHost: host, + wsPath: `/${stage}?`, // The trailing "?" is required + wsPort: 80, + wssPort: 443, + forceTLS: true, + enabledTransports: ['ws', 'wss'], + // Ping every 9 minutes instead of 2: each ping costs a Lambda invocation and 2 messages + activityTimeout: 540000, + }); +} +``` + +### Deploy + + + + ```bash + bref deploy + ``` + + + ```bash + serverless deploy + ``` + + + +With the database store, also run the migration: see [Laravel Artisan commands](/docs/laravel/getting-started#laravel-artisan). + +### Restrict origins + +By default, any website can open a connection. To allow only your domains: + +```yml filename="serverless.yml" +provider: + # ... + environment: + # ... + BREF_WEBSOCKET_ALLOWED_ORIGINS: 'example.com,*.example.com' +``` + +### Local development + +The `api-gateway` driver needs AWS. Set `BROADCAST_CONNECTION=log` in your local `.env`: events are written to the logs, and Echo does not connect. + +## API Gateway or a Reverb server + +API Gateway charges for each message delivered: about $1.25 to $1.50 per million all included in `eu-west-3`, and almost nothing when idle. What counts is **connections × events**, more than the number of connections. + +| Use case | Messages per month | API Gateway | Use | +|---|---|---|---| +| Notifications: 20 connections, 1 event per minute | 0.9 million | $1 to $2 | API Gateway | +| Live back office: 20 connections, 1 event per second, office hours | 12.7 million | $19 | API Gateway | +| Dashboard on a screen: 20 connections, 1 event per second, 24/7 | 52 million | $78 | Either, depending on your budget | +| Public website: 1000 connections, 10 events per minute | 432 million | $545 | A Reverb server | + +Start with API Gateway. Above about 50 million messages per month, or when an event regularly reaches many people, run Laravel Reverb on a small always-on server instead. An [Amazon Lightsail](https://aws.amazon.com/lightsail/) container (nano, $7 per month with 500 GB of transfer included) handled 1000 connections and 10 events per minute at about 1% CPU. + +Your events, channels and Echo code stay the same: + +- install the `uv` PHP extension in the Reverb container: without it, Reverb stops at about 1000 connections, +- set `BROADCAST_CONNECTION=reverb` and the `REVERB_*` variables in the application, +- in Echo, remove `wsPath` and set `wsHost` to the address of the server, +- use queued broadcasts (`ShouldBroadcast`), because events cannot be sent while the server restarts. + +A single server is a single point of failure: clients reconnect by themselves, but events sent during an outage are lost. + +## Limits + +- Events over 128 KB throw a `BroadcastException`, because API Gateway refuses them. The size is measured once encoded, where quotes count twice, so a JSON payload can reach the limit at about 100 KB. +- Messages are billed per 32 KB: a 33 KB event counts as two messages per connection. +- [Encrypted private channels](https://laravel.com/docs/broadcasting#encrypted-private-channels) are not supported. +- API Gateway closes connections after 2 hours. Echo reconnects and subscribes again by itself, but events sent during those few hundred milliseconds are lost. +- API Gateway accepts 500 new connections per second by default, per account and region. +- If Lambda throttles the `websocket` function, a subscription can be lost, and Echo does not retry it. Make sure your [concurrency limit](https://docs.aws.amazon.com/lambda/latest/dg/lambda-concurrency.html) leaves room for reconnections. +- Events sent in parallel have no ordering guarantee. diff --git a/docs/use-cases/websockets.mdx b/docs/use-cases/websockets.mdx index 6e9115365..08e9d7e4a 100644 --- a/docs/use-cases/websockets.mdx +++ b/docs/use-cases/websockets.mdx @@ -17,6 +17,10 @@ B3(Browser):::mermaidBlack -->|WebSocket connection| API; API --> Lambda(Lambda):::mermaidAwsColor; ``` +> [!TIP] +> +> Using Laravel? Follow the [WebSockets with Laravel Broadcasting guide](/docs/laravel/websockets.mdx): Laravel Echo works out of the box, there is no handler to write. + To handle WebSocket events, extend the `WebsocketHandler` class: ```php diff --git a/website/src/components/home/use-cases.jsx b/website/src/components/home/use-cases.jsx index 2eaa2f9a3..aa13063df 100644 --- a/website/src/components/home/use-cases.jsx +++ b/website/src/components/home/use-cases.jsx @@ -34,7 +34,7 @@ const advancedUseCases = [ }, { name: 'WebSockets', - description: 'AWS API Gateway manages the WebSocket connections for you. Send messages to your users in real-time.' + description: 'AWS API Gateway manages the WebSocket connections for you. Send messages to your users in real-time, with Laravel Echo if you use Laravel.' }, ]; From 53080d9799f74c82ca6957202ca814da62fb65b9 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Thu, 5 Nov 2026 20:55:59 +0100 Subject: [PATCH 2/7] Mention the WebSocket metrics of Bref Cloud --- docs/cloud.mdx | 2 +- docs/laravel/websockets.mdx | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/cloud.mdx b/docs/cloud.mdx index 93cf56d8d..5e3ab270f 100644 --- a/docs/cloud.mdx +++ b/docs/cloud.mdx @@ -29,7 +29,7 @@ To get started, [create a Bref Cloud account](https://bref.cloud/register). Ther - **Overview**: a diagram of each environment's architecture with live metrics on every component. - **Logs**: search logs or tail them in real time in the dashboard, or search them from the terminal with [`bref logs`](/docs/environment/logs#reading-logs). -- **Metrics**: Lambda invocations, concurrency, duration and errors, API Gateway, queues and dead-letter queues. +- **Metrics**: Lambda invocations, concurrency, duration and errors, API Gateway, WebSocket APIs, queues and dead-letter queues. - **Traces**: a trace explorer optimized for PHP applications, with a free [Bref X-Ray](/xray) license included. See database queries, HTTP calls and AWS calls inside each invocation, and filter traces by route, job, command, cold start, or your own annotations, over up to 30 days. - **Performance**: the slowest database queries, the latency of every route, and the slowest jobs of your application, computed from the last 30 days of traces. - **Health checks**: verify that the database, the cache and the Lambda configuration of a deployed application are healthy (Laravel only for now). diff --git a/docs/laravel/websockets.mdx b/docs/laravel/websockets.mdx index 22d996e7e..932553a10 100644 --- a/docs/laravel/websockets.mdx +++ b/docs/laravel/websockets.mdx @@ -218,6 +218,8 @@ Your events, channels and Echo code stay the same: A single server is a single point of failure: clients reconnect by themselves, but events sent during an outage are lost. +With Bref Cloud, the **Metrics** page of an environment shows its WebSocket messages and their estimated cost, as well as new connections, errors and latency. + ## Limits - Events over 128 KB throw a `BroadcastException`, because API Gateway refuses them. The size is measured once encoded, where quotes count twice, so a JSON payload can reach the limit at about 100 KB. From fc228bc531b30d1152f8c271c7dd43879623ba82 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Fri, 6 Nov 2026 20:17:25 +0100 Subject: [PATCH 3/7] Open the Laravel WebSockets docs with what works --- docs/laravel/websockets.mdx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/laravel/websockets.mdx b/docs/laravel/websockets.mdx index 932553a10..82ccb12c7 100644 --- a/docs/laravel/websockets.mdx +++ b/docs/laravel/websockets.mdx @@ -6,9 +6,11 @@ import { Tabs } from 'nextra/components'; # WebSockets with Laravel Broadcasting -[Laravel Reverb](https://laravel.com/docs/reverb) cannot run on AWS Lambda, because it is a long-running process. With the [`bref/laravel-websockets`](https://github.com/brefphp/laravel-websockets) package, API Gateway holds the WebSocket connections instead, and there is no server to run. +Laravel broadcasting works on AWS Lambda as described in [the Laravel documentation](https://laravel.com/docs/broadcasting): `ShouldBroadcast` events, `routes/channels.php`, and Laravel Echo with private channels, presence channels and client events (whispers). -Laravel 12 or later is required. Broadcasting then works as described in [the Laravel documentation](https://laravel.com/docs/broadcasting): `ShouldBroadcast` events, `routes/channels.php`, and Laravel Echo with private channels, presence channels and client events (whispers). +You don't need a [Reverb](https://laravel.com/docs/reverb) server. With the [`bref/laravel-websockets`](https://github.com/brefphp/laravel-websockets) package, API Gateway holds the WebSocket connections and Lambda runs your application when an event happens, so there is no server to manage. + +Laravel 12 or later is required. ## Installation From 9494bd4d38a05255864929087d586e21a51b074b Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Fri, 6 Nov 2026 20:38:37 +0100 Subject: [PATCH 4/7] Simplify the opening of the Laravel WebSockets docs --- docs/laravel/websockets.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/laravel/websockets.mdx b/docs/laravel/websockets.mdx index 82ccb12c7..0b7f5c5c5 100644 --- a/docs/laravel/websockets.mdx +++ b/docs/laravel/websockets.mdx @@ -6,7 +6,7 @@ import { Tabs } from 'nextra/components'; # WebSockets with Laravel Broadcasting -Laravel broadcasting works on AWS Lambda as described in [the Laravel documentation](https://laravel.com/docs/broadcasting): `ShouldBroadcast` events, `routes/channels.php`, and Laravel Echo with private channels, presence channels and client events (whispers). +You can use WebSockets in Laravel on AWS Lambda. Laravel Broadcasting and Laravel Echo work just like in [the Laravel documentation](https://laravel.com/docs/broadcasting). You don't need a [Reverb](https://laravel.com/docs/reverb) server. With the [`bref/laravel-websockets`](https://github.com/brefphp/laravel-websockets) package, API Gateway holds the WebSocket connections and Lambda runs your application when an event happens, so there is no server to manage. From 96e42a16115d3c593b0358088ea9b8a856abffc9 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Fri, 6 Nov 2026 23:43:08 +0100 Subject: [PATCH 5/7] Warn about install:broadcasting before the manual setup --- docs/laravel/websockets.mdx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/laravel/websockets.mdx b/docs/laravel/websockets.mdx index 0b7f5c5c5..c951c8c1d 100644 --- a/docs/laravel/websockets.mdx +++ b/docs/laravel/websockets.mdx @@ -21,7 +21,7 @@ npm install laravel-echo pusher-js ### Enable broadcasting -Declare the channels file in `bootstrap/app.php`: +Do not run `php artisan install:broadcasting`: it requires choosing one of Laravel's drivers. Instead, declare the channels file in `bootstrap/app.php`: ```php filename="bootstrap/app.php" ->withRouting( @@ -33,8 +33,6 @@ Declare the channels file in `bootstrap/app.php`: Then create `routes/channels.php` as described in [the Laravel documentation](https://laravel.com/docs/broadcasting#defining-authorization-callbacks). -Do not run `php artisan install:broadcasting`: it requires choosing one of Laravel's drivers. - ### Create the WebSocket API Add this to `serverless.yml`: From 0cff46e3bc725fb5581fd9b9e56d007476465c80 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Fri, 6 Nov 2026 23:46:11 +0100 Subject: [PATCH 6/7] Explain the self-invocation permission, drop the VPC note --- docs/laravel/websockets.mdx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/laravel/websockets.mdx b/docs/laravel/websockets.mdx index c951c8c1d..bc810ee01 100644 --- a/docs/laravel/websockets.mdx +++ b/docs/laravel/websockets.mdx @@ -51,6 +51,7 @@ provider: - Effect: Allow Action: execute-api:ManageConnections Resource: !Sub 'arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${WebsocketsApi}/*' + # The websocket function invokes itself when a connection opens - Effect: Allow Action: lambda:InvokeFunction Resource: !Sub 'arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${self:service}-${sls:stage}-websocket' @@ -67,8 +68,6 @@ functions: - websocket: $default ``` -If your application runs in a VPC, give this function the same `vpc` configuration as your other functions. Publishing events requires internet access, for example through a NAT Gateway. - ### Store subscriptions in the database or DynamoDB The application stores which connection listens to which channel, in your database by default: From 7be2c326e2e719896f1c1205df7a1da287695d81 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Sat, 7 Nov 2026 00:11:08 +0100 Subject: [PATCH 7/7] Create the DynamoDB table of Laravel WebSockets with Lift --- docs/laravel/websockets.mdx | 53 ++++++++++++++----------------------- 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/docs/laravel/websockets.mdx b/docs/laravel/websockets.mdx index bc810ee01..aae41fd6a 100644 --- a/docs/laravel/websockets.mdx +++ b/docs/laravel/websockets.mdx @@ -75,7 +75,7 @@ The application stores which connection listens to which channel, in your databa | | Database (default) | DynamoDB | |---|---|---| | **Use it for** | Applications with a database and little traffic, back offices, preview environments | Many connections, frequent reconnections, or no database | -| **Setup** | Run `php artisan migrate` | Add a table and permissions to `serverless.yml` | +| **Setup** | Run `php artisan migrate` | Add the Lift plugin and a table to `serverless.yml` | | **Cost** | Nothing more | Less than $3 per month for 1000 connections | | **Time per operation** | 3 to 4 ms | 3 to 4 ms | | **First operation of a request** | 12 to 29 ms | 34 to 47 ms | @@ -83,7 +83,13 @@ The application stores which connection listens to which channel, in your databa If your database pauses when idle (like Aurora Serverless), note that each browser tab left open writes to it every 2 hours, which keeps it awake. -To use DynamoDB: +To use DynamoDB, install the [Serverless Lift](https://github.com/getlift/lift) plugin: + +```bash +npm install --save-dev serverless-lift +``` + +Then enable it and create the table in `serverless.yml`: ```yml filename="serverless.yml" provider: @@ -91,39 +97,20 @@ provider: environment: # ... BREF_WEBSOCKET_STORE: dynamodb - BREF_WEBSOCKET_DYNAMODB_TABLE: !Ref WebsocketSubscriptions - iam: - role: - statements: - # ... - - Effect: Allow - Action: [dynamodb:Query, dynamodb:GetItem, dynamodb:PutItem, dynamodb:DeleteItem] - Resource: - - !GetAtt WebsocketSubscriptions.Arn - - !Sub '${WebsocketSubscriptions.Arn}/index/*' - -resources: - Resources: - WebsocketSubscriptions: - Type: AWS::DynamoDB::Table - Properties: - BillingMode: PAY_PER_REQUEST - AttributeDefinitions: - - { AttributeName: channel, AttributeType: S } - - { AttributeName: connectionId, AttributeType: S } - KeySchema: - - { AttributeName: channel, KeyType: HASH } - - { AttributeName: connectionId, KeyType: RANGE } - GlobalSecondaryIndexes: - - IndexName: by-connection - KeySchema: - - { AttributeName: connectionId, KeyType: HASH } - Projection: { ProjectionType: ALL } - TimeToLiveSpecification: - AttributeName: expiresAt - Enabled: true + BREF_WEBSOCKET_DYNAMODB_TABLE: ${construct:websocket-subscriptions.tableName} + +plugins: + # ... + - serverless-lift + +constructs: + websocket-subscriptions: + type: database/dynamodb-single-table + gsiCount: 1 ``` +The table is kept when you remove the environment: delete it in the AWS console if you no longer need it. + ### Connect Laravel Echo Each environment has its own WebSocket API, so give its address to the frontend at runtime, in your layout: