How to stream Postgres to S2
Connect Postgres to S2 with Sequin. Stream database changes for real-time analytics and event-driven pipelines.
This guide shows you how to set up Postgres change data capture (CDC) and stream changes to an S2 stream using Sequin.
With Postgres data streaming to S2 you can trigger event-driven workflows, feed analytics pipelines, and fan-out events to other services.
By the end of this how-to, you’ll have database changes flowing to an S2 stream.
Prerequisites
If you’re self-hosting Sequin, you’ll need:
If you’re using Sequin Cloud, you’ll need:
And for S2 you’ll need:
- A S2 Cloud account
- The S2 CLI installed (optional but recommended)
Basic setup
Create an S2 Access Token
In the S2 web console, open the Access Tokens page and click + Issue to generate a new token.
Save this token in a secure location—you’ll use it to configure both the S2 CLI and your Sequin S2 sink.
Create a basin and stream
If you don’t already have a basin and stream, create them via the S2 console or the CLI:
You can also perform these steps in the S2 console by navigating to Basins → + Create Basin and then + Create Stream.
You can configure S2 Basins to automatically create streams when you create a new sink in Sequin by enabling the Create stream on append
option in the S2 console or passing the --create-stream-on-append
flag to the s2 create-basin
command.
Your S2 stream is now ready to receive data.
Create an S2 sink
Navigate to the Sinks tab in the Sequin console, click Create Sink, and choose S2 as the sink type.
Configure the source
Select source schemas and tables
Under Source, pick the schemas and tables you want to stream data from.
Specify filters
You can restrict to insert
, update
, and/or delete
actions, and you can apply additional filters.
Specify backfill
Optionally send a backfill of existing rows. Disable Backfill if you only want new changes.
Configure S2
Enter connection details
In the S2 configuration card, enter:
- Basin – the basin name you created earlier (e.g.
my-basin
) - Stream – the stream name (e.g.
products
) - Access Token – the S2 access token you generated
Create the sink
Give your sink a name and click Create Sink.
Verify & debug
To verify that your S2 sink is working:
-
Make a change in your source table.
-
Confirm that the Messages count for your sink increases in the Sequin console, and observe the new message in the Messages tab.
-
Use the S2 CLI to read from the stream and confirm events arrive:
If messages don’t seem to be flowing:
- Open the sink’s Messages tab to inspect in-flight, failed, and delivered messages.
- Click a failed message to see delivery logs and error details returned by S2.
Next steps
-
Process the events
Build a consumer that reads from your S2 stream and processes the data.
-
Deploy your implementation
When you’re ready, follow “How to deploy to production”.
-
Advanced configuration
Learn about batching, ordering guarantees, and other options in the S2 sink reference.
-
Start from scratch
If you need a more guided tutorial, check out the S2 sink quickstart.