How to stream PostgreSQL changes to Amazon S3 with AWS Fargate
Database Blog
This article demonstrates how to build an event-driven change data capture (CDC) pipeline that streams PostgreSQL row-level changes to Amazon S3 in near real time using AWS Fargate, EventBridge, SQS, and Lambda.
- Pipeline uses PostgreSQL's Write-Ahead Log (WAL) and logical replication to capture changes without polling
- Fargate CDC reader continuously polls replication slot and publishes events to EventBridge
- EventBridge routes events to SQS for buffering; Lambda consumes batches and writes partitioned JSON to S3
- Supports private subnet deployments with VPC endpoints and no internet gateway exposure
- Deploy entire pipeline with single CloudFormation template; costs approximately $9/month for Fargate at low volume
- Includes operational guidance for monitoring replication lag, handling Fargate restarts, and managing Lambda failures
- Supports three output plugins: pgoutput (binary), wal2json (structured JSON), and test_decoding (plain text)
This serverless CDC approach eliminates Kafka dependencies, provides pay-per-use pricing, and simplifies operational complexity compared to traditional batch jobs or polling mechanisms.
The AWS News Feed is currently looking for gold sponsors. If you want to support the AWS community and reach a large audience of AWS professionals, consider sponsoring the AWS News Feed.
Related articles
2026
2026
2026
2026
The AWS News Feed is currently looking for silver sponsors. If you want to support the AWS community and reach a large audience of AWS professionals, consider sponsoring the AWS News Feed.