How to stream Postgres to AWS SNS
Setup Postgres change data capture (CDC) and stream changes to Amazon SNS topics with Sequin. Power event-driven architectures, fan‑out to SQS queues, Lambdas, and more.
This guide shows you how to set up Postgres change data capture (CDC) and stream changes to Amazon SNS using Sequin.
With Postgres data streaming to SNS you can fan‑out events to SQS queues, trigger AWS Lambdas, send emails, stream to AWS Kinesis, and more.
By the end of this how‑to, you’ll have database changes flowing into an SNS topic.
Prerequisites
If you’re self‑hosting Sequin, you’ll need:
- Sequin installed
- A database connected
- An AWS account
If you’re using Sequin Cloud, you’ll need:
- A Sequin Cloud account
- A database connected
- An AWS account
Basic setup
Create an SNS topic
If you don’t have a topic already, create one in the SNS console:
- Click “Create topic”.
- Choose “Standard” unless you need FIFO ordering. Note that FIFO SNS topics can only fan‑out to SQS queues. (Read more about FIFO vs standard topics in the reference.)
- Give the topic a name, e.g.
postgres-changes
. - Click “Create topic”.
- Copy the Topic ARN – you’ll need it when configuring the sink.
Create an IAM user for Sequin
Create an IAM user with permission to publish to the topic:
-
Open the IAM console.
-
Click “Users” → “Add users”.
-
Name the user (e.g.
sequin-sns-publisher
) and select “Access key – Programmatic access”. -
Attach the policy below (replace
<your-topic-arn>
): -
Finish the wizard and save the Access Key ID and Secret Access Key. You’ll enter these in Sequin next.
(Optional) Enable retention for changes
You can stream either changes or rows to SNS. Changes are transient; if you need to replay them later consider change retention or streaming a retention table instead.
Create SNS sink
In Sequin, navigate to the “Sinks” tab, click “Create Sink”, and select “SNS Sink”.
Configure the source
Select source table
Under Source, choose the table you want to stream.
Choose message type
Decide whether to receive changes or rows. If unsure, start with Changes.
Specify filters
For changes you can restrict to insert
, update
, and/or delete
actions and add SQL filters such as mrr > 100
.
Specify transforms
Optionally transform the shape of messages using transforms.
Specify backfill
Optionally send a backfill of existing rows. Toggle Backfill off if you only need new changes.
Specify message grouping
Leave the default grouping (primary key) so events for the same row share a MessageGroupId
when using FIFO topics.
Configure SNS
Enter topic details
Fill in:
- Topic ARN (required): The ARN you copied earlier.
- AWS Access Key ID / Secret Access Key (required): Credentials you created for Sequin.
Test connection
Click “Test Connection” to ensure Sequin can publish to the topic.
Create the sink
Give your sink a name, then click “Create SNS Sink”.
Verify & debug
To verify your sink:
- Make changes in the source table.
- Watch the message count increase in Sequin’s “Messages” tab.
- Check your subscription (email, SQS queue, etc.) – you should receive the events.
If messages aren’t flowing:
- In Sequin click the “Messages” tab.
- Inspect any failed message to see the AWS error.
- Confirm:
- Credentials are correct and active.
- IAM policy includes
sns:Publish*
permissions for the topic. - Topic ARN and region are correct.
Next steps
-
Process the events
Subscribe an SQS queue or Lambda function to the topic and build your processor. Refer to the SNS sink reference for the exact message shape.
-
Deploy to production
When you’re ready, see “How to deploy to production”.
-
Advanced configuration
Explore transforms, filtering, and grouping options in the sink reference.