AWS Builder Center
Building a Real-Time Data Pipeline Using AWS Kinesis and S3: Integrating Snowflake for Analytics

Building a Real-Time Data Pipeline Using AWS Kinesis and S3: Integrating Snowflake for Analytics

From streaming events to analytics-ready data: learn how Amazon Kinesis Data Streams, Amazon Data Firehose, Amazon S3, and Snowflake work together to build a scalable real-time data pipeline.

Cloud Data Engineer
Modern applications generate data continuously. E-commerce transactions, application logs, IoT sensors, payment events, and user activity can produce thousands or even millions of records that need to be processed and analyzed.
Traditional batch pipelines often introduce delays because data is collected first and processed later. Real-time data pipelines reduce that delay by continuously ingesting, buffering, and delivering events to downstream systems.
In this article, we'll explore how to build a real-time data pipeline using AWS services, following the architecture in the accompanying diagram:
Amazon Kinesis Data Streams → Amazon Data Firehose → Snowflake, with Amazon S3 configured to store failed or backup records.
We'll cover ingestion, buffering, delivery streams, partitioning, failure handling, and Snowflake integration.




1. Understanding the Architecture

The proposed pipeline has four main components:
  1. Amazon Kinesis Data Streams: Ingests and temporarily stores streaming records.
  1. Amazon Data Firehose: Reads records from Kinesis, buffers them, and manages delivery to the destination.
  1. Amazon S3: Stores backup or failed-delivery records for recovery and investigation.
  1. Snowflake: Receives streaming data and makes it available for analytical workloads.

Architecture flow

AWS Region
+---------------------------+
| |
| Amazon Kinesis |
| Data Streams |
| | |
| v |
| Amazon Data Firehose |-------> Snowflake
| | | Data Warehouse
| | |
| v |
| Amazon S3 |
| Error / Backup Records |
| |
+---------------------------+
The diagram is a logical architecture. Kinesis Data Streams and Data Firehose are managed AWS services; they are not customer-managed servers deployed inside a VPC. Network connectivity and access controls should be configured according to the chosen service integration.
The key advantage is separation of responsibilities: Kinesis handles ingestion, Firehose handles managed delivery, S3 provides a recovery location, and Snowflake supports analytics.

2. Data Ingestion with Amazon Kinesis Data Streams

The first stage is collecting events from applications and producers.
Amazon Kinesis Data Streams is a managed streaming service that ingests, stores, and makes streaming records available to consumers in near real time. Records are distributed across shards. Each shard provides a base throughput unit for reading and writing data.  https://docs.aws.amazon.com/streams/latest/dev/working-with-streams.html 

Example data sources

Imagine an online retail platform generating events such as:
  • Customer registrations
  • Product views
  • Shopping cart updates
  • Order placements
  • Payment transactions
  • Shipment status changes
Instead of waiting for a daily batch export, applications can publish these events to a Kinesis data stream as they occur.

Example event

A producer might publish a JSON event like this:
{
"event_id": "evt-10001",
"event_type": "order_placed",
"customer_id": "customer-501",
"order_id": "order-9001",
"amount": 249.99,
"currency": "USD",
"event_timestamp": "2026-11-09T08:30:00Z"
}
Each event contains useful information that downstream systems can process.

Publishing records using Python

The following example uses Boto3 to publish an event to Kinesis Data Streams.
import boto3
import json
from datetime import datetime, timezone

kinesis = boto3.client("kinesis", region_name="us-east-1")

event = {
"event_id": "evt-10001",
"event_type": "order_placed",
"customer_id": "customer-501",
"order_id": "order-9001",
"amount": 249.99,
"currency": "USD",
"event_timestamp": datetime.now(timezone.utc).isoformat()
}

response = kinesis.put_record(
StreamName="orders-stream",
Data=json.dumps(event).encode("utf-8"),
PartitionKey=event["customer_id"]
)

print("Sequence number:", response["SequenceNumber"])
print("Shard ID:", response["ShardId"])
The producer sends three important pieces of information:
  • Stream name
  • Data payload
  • Partition key
The partition key determines which shard receives the record. Choosing a good key helps distribute traffic and preserve ordering for records sharing that key.  https://docs.aws.amazon.com/streams/latest/dev/building-producers.html 

Understanding shards and capacity

A shard is a fundamental throughput unit in Kinesis Data Streams.
AWS documents the following shard throughput limits:
Operation
Per-shard throughput
Write throughput
1 MB/second
Write records
1,000 records/second
Read throughput
2 MB/second
These limits are important when estimating stream capacity. Actual application throughput also depends on record sizes, consumers, aggregation, and the selected capacity mode.  https://docs.aws.amazon.com/streams/latest/dev/working-with-streams.html 
For higher workloads, evaluate on-demand capacity or provisioned shard scaling based on the traffic pattern.

3. Amazon Data Firehose: Managed Delivery

After ingestion, the next component is Amazon Data Firehose, formerly known as Amazon Kinesis Data Firehose.
Firehose is a managed delivery service. It reads records from supported sources, buffers incoming data, and delivers it to configured destinations.
In this architecture, Kinesis Data Streams is the source and Snowflake is the primary destination.

Why use Firehose?

Without a managed delivery service, developers may need to build and operate custom consumers that handle:
  • Reading records
  • Batching events
  • Buffering
  • Retry logic
  • Destination connectivity
  • Delivery monitoring
  • Failure handling
Firehose manages much of this delivery workflow.

Connecting Kinesis Data Streams to Firehose

When configuring a Firehose delivery stream:
  1. Create or select an existing Kinesis data stream.
  1. Choose Kinesis Data Streams as the source.
  1. Configure the source stream ARN.
  1. Set up the destination as Snowflake.
  1. Configure authentication and destination details.
  1. Select an S3 backup location for failed records.
  1. Configure logging, retry behavior, and monitoring.
One important detail: when a Kinesis data stream is configured as the Firehose source, producers must write to Kinesis Data Streams using its APIs, such as  PutRecord  or  PutRecords . The Firehose  PutRecord  and  PutRecordBatch  APIs are disabled for that source configuration.  https://docs.aws.amazon.com/firehose/latest/dev/writing-with-kinesis-streams.html 
Firehose starts reading from the  LATEST  position when configured with a Kinesis data stream source. Plan the stream and delivery setup accordingly, especially when historical records must also be processed.

4. Understanding Buffering in Firehose

Buffering is an important part of streaming architecture.
Firehose collects incoming records before delivering them to the destination. This reduces the overhead of sending every small event individually.
Buffering is generally configured using two hints:
  • Buffer size: The amount of data collected before delivery.
  • Buffer interval: The maximum time Firehose waits before attempting delivery.
For example, a configuration might use a size threshold of 5 MiB and an interval of 60 seconds.
These are configuration hints, not guaranteed delivery times. Firehose may use different values when optimal for the destination.  https://docs.aws.amazon.com/firehose/latest/dev/buffering.html 

Why does buffering matter?

Consider an application generating 100 small events per second.
Sending every event independently to a destination can create unnecessary request overhead.
Buffering allows the delivery service to manage the flow more efficiently.
However, buffering introduces a trade-off:
Smaller buffer interval
Larger buffer interval
Lower delivery delay
Potentially higher delivery delay
More frequent delivery activity
More batching
Useful for freshness-sensitive workloads
Useful for throughput-oriented workloads

Snowflake-specific behavior

Firehose uses Snowflake streaming API operations for delivery. AWS documents that Firehose internally buffers Snowflake-bound data for approximately one second by default and flushes records to the Snowflake table at that frequency.
Firehose also emits a CloudWatch metric measuring how long records take to be committed to Snowflake.
For this destination, the input must be a valid, well-formed JSON object. Firehose's Snowflake integration does not support JSON arrays as record payloads.  https://docs.aws.amazon.com/firehose/latest/dev/basic-deliver.html 
This distinction is important when designing the producer's event format.

5. Partitioning: Organizing Streaming Data

Partitioning helps organize data so that downstream analytical systems can access relevant records efficiently.
There are two different partitioning concepts to understand in this architecture.

A. Kinesis partition keys

Kinesis Data Streams uses partition keys to determine which shard receives a record.
For example:
PartitionKey="customer-501"
Records with the same partition key are routed to the same shard, preserving their order within that shard.
However, using a low-cardinality key such as a single country or event type for all records may create uneven traffic distribution.
For example, if most events belong to one customer, that customer's partition key may create a hot shard.
Choose keys based on your ordering requirements and traffic distribution.

B. Firehose dynamic partitioning for Amazon S3

Amazon Data Firehose also supports dynamic partitioning for records delivered to Amazon S3.
It can extract values from JSON records and organize objects into S3 prefixes.
For example, consider this event:
{
"event_type": "order_placed",
"region": "us-east-1",
"event_date": "2026-11-09",
"customer_id": "customer-501",
"amount": 249.99
}
A possible S3 prefix structure is:
s3://company-streaming-data/
region=us-east-1/
event_date=2026-11-09/
records.json
This makes it easier to query data by date or region using services such as Amazon Athena.
Dynamic partitioning uses keys extracted from records and routes them to corresponding S3 prefixes. It is a feature for S3 delivery, not a general-purpose partitioning setting for the direct Snowflake destination.  https://docs.aws.amazon.com/firehose/latest/dev/dynamic-partitioning.html 

Avoid over-partitioning

Creating too many small partitions can result in many small files and additional processing overhead.
For S3 analytics, choose partition keys that match common query filters, such as:
  • Event date
  • Region
  • Event category
  • Business unit
Avoid partitioning by highly unique values such as individual transaction IDs unless there is a specific requirement.
Also note that dynamic partitioning creates separate buffers for active partitions. AWS documents a default active-partition limit of 500 per Firehose stream, with a quota-increase process available.  https://docs.aws.amazon.com/firehose/latest/dev/buffering.html 

6. Snowflake Integration: Delivering Streaming Data to the Warehouse

Snowflake is a cloud data platform used for data warehousing, analytics, and data engineering workloads.
In this architecture, Snowflake is the primary analytical destination.
The integration allows Firehose to deliver streaming records directly to Snowflake using the Snowflake streaming API.

Configuration requirements

When configuring Snowflake as a Firehose destination, you need to provide:
  • Snowflake account URL
  • Snowflake user
  • Private key authentication details
  • Database
  • Schema
  • Table
  • Appropriate permissions
  • S3 backup configuration
AWS supports retrieving Snowflake credentials from AWS Secrets Manager rather than placing sensitive credentials directly in application configuration.  https://docs.aws.amazon.com/firehose/latest/dev/create-destination.html 
Check the current AWS Region availability for the Snowflake destination before designing the deployment.

Preparing the Snowflake table

One approach is to store the complete incoming JSON event in a  VARIANT  column.
Example:
CREATE DATABASE STREAMING_DB;

CREATE SCHEMA STREAMING_DB.RAW;

CREATE TABLE STREAMING_DB.RAW.ORDER_EVENTS (
EVENT_DATA VARIANT
);
A  VARIANT  column can store semi-structured data, making it useful when event schemas evolve over time.
For example, after ingestion, you can query the order ID and amount:
SELECT
EVENT_DATA:order_id::STRING AS ORDER_ID,
EVENT_DATA:customer_id::STRING AS CUSTOMER_ID,
EVENT_DATA:amount::NUMBER(10,2) AS AMOUNT,
EVENT_DATA:event_timestamp::TIMESTAMP_TZ AS EVENT_TIME
FROM STREAMING_DB.RAW.ORDER_EVENTS;
Alternatively, Firehose can map JSON keys to Snowflake columns. Select the data-loading approach that matches your schema and downstream analytics requirements.

Why use Snowflake?

Once data reaches Snowflake, teams can use it for:
  • Real-time operational analytics
  • Customer behavior analysis
  • Sales and transaction reporting
  • Business intelligence dashboards
  • Data science and machine learning
  • Historical trend analysis
The streaming pipeline makes new data available without requiring the application team to operate a custom warehouse-loading service.

7. Amazon S3: Backup and Error Handling

A production pipeline needs a recovery strategy.
What happens if Snowflake becomes temporarily unavailable? What if a record cannot be delivered? What if a payload has an unexpected format?
This is where Amazon S3 becomes important.
For a Firehose stream with Snowflake as its destination, configure an S3 backup location for error data.
A possible structure is:
s3://company-streaming-backup/
snowflake-errors/
year=2026/
month=11/
day=09/
failed-records/
The exact prefix depends on your Firehose configuration.

What happens when delivery fails?

Firehose retries delivery according to the configured retry duration. If the retry period expires before successful delivery, it backs up the data to the configured S3 backup bucket.  https://docs.aws.amazon.com/firehose/latest/dev/troubleshooting.html 
This provides a location for investigation and recovery.

Why store failed records?

S3 backup records can help teams:
  • Investigate malformed events
  • Identify destination connectivity issues
  • Reprocess records after fixing a problem
  • Maintain an audit trail
  • Build data-quality monitoring
  • Recover from temporary downstream failures
Do not assume that writing a record to S3 automatically replays it into Snowflake. A separate, controlled recovery process is needed to validate and redeliver failed records.

Recommended S3 controls

For production deployments, consider:
  • Server-side encryption with AWS KMS
  • Restricted IAM access
  • S3 versioning where appropriate
  • Lifecycle policies
  • CloudTrail data events when required
  • Monitoring for failed delivery and backup activity
S3 should be treated as a recovery and data-management component, not simply an unlimited dumping ground.

8. Monitoring and Troubleshooting the Pipeline

A real-time pipeline is only useful when teams can observe its health.
Amazon CloudWatch provides metrics and logs that can help identify ingestion, delivery, and processing problems.
Monitor the following areas:
Component
What to monitor
Kinesis Data Streams
Incoming records, incoming bytes, write throttling, iterator age
Firehose
Incoming records, data read from Kinesis, delivery success, delivery failures
S3
Backup object creation, storage growth, access failures
Snowflake
Data freshness, committed records, ingestion errors
IAM
Access denied errors and role permissions
For Firehose reading from Kinesis, AWS specifically recommends checking the Kinesis source metrics and Firehose's  DataReadFromKinesisStream.Bytes  and  DataReadFromKinesisStream.Records  metrics.  https://docs.aws.amazon.com/firehose/latest/dev/troubleshooting.html 

Common problems

1. Records are not reaching Firehose
Check the source stream ARN, IAM permissions, Kinesis incoming records, and Firehose source-read metrics.
2. Records are not reaching Snowflake
Check the Snowflake account URL, authentication, user permissions, destination configuration, and CloudWatch error logs.
3. Invalid JSON records
Validate producer payloads. Send individual JSON objects rather than arrays of JSON objects for the Snowflake destination.
4. Unexpected delivery delays
Review destination buffering, source throughput, retry activity, and Snowflake commit metrics.
5. S3 backup contains records
Inspect the error details and determine whether the issue is caused by payload formatting, authentication, destination availability, or configuration.

9. Best Practices for a Production-Ready Pipeline

A reliable pipeline requires more than connecting four services.
Consider these engineering practices:

Design a consistent event schema

Use stable field names, event IDs, timestamps, and version information.
For example:
{
"event_id": "evt-10001",
"event_type": "order_placed",
"schema_version": "1.0",
"event_timestamp": "2026-11-09T08:30:00Z",
"source": "checkout-service",
"payload": {
"order_id": "order-9001",
"amount": 249.99
}
}

Select partition keys carefully

Choose Kinesis partition keys that distribute traffic while meeting ordering requirements.
For S3 dynamic partitioning, use fields that support common analytical filters.

Secure credentials

Use IAM roles for AWS service access and AWS Secrets Manager for Snowflake credentials. Avoid hardcoding secrets in source code.

Plan for retries and duplicates

Design downstream processing to handle retries safely. Use stable event identifiers and deduplication logic where necessary.

Monitor data freshness

Measure the time between event creation and successful delivery to Snowflake.

Control storage costs

Use S3 lifecycle policies to manage old backup objects and select suitable storage classes based on recovery requirements.

Test failure scenarios

Test invalid JSON, expired credentials, destination outages, throttling, and recovery workflows before production deployment.

10. When Should You Use This Architecture?

This architecture is useful when applications need managed streaming ingestion and a direct delivery path into Snowflake.
Potential use cases include:
Use case
Example
E-commerce
Stream orders and customer activity
Financial services
Process transaction events
IoT
Ingest sensor readings
Application monitoring
Stream logs and application events
Customer analytics
Analyze clickstream behavior
Operations
Monitor service and business events
It is especially useful when teams want to avoid maintaining custom consumers and delivery infrastructure.
For use cases that need custom stream processing, complex transformations, or multiple independent consumers, consider adding dedicated Kinesis consumers or other processing services.

Conclusion: From Streaming Events to Real-Time Analytics

Building a real-time data pipeline does not necessarily require a large collection of custom applications.
Amazon Kinesis Data Streams provides the ingestion layer. Amazon Data Firehose manages buffering and delivery. Amazon S3 provides a recovery location for failed records. Snowflake turns incoming events into data that analytics teams can query and use.
The architecture creates a managed path from application events to analytical insights.
The most important design considerations are choosing suitable partition keys, understanding buffering behavior, validating event formats, securing Snowflake credentials, monitoring delivery, and planning for recovery.
Real-time analytics starts with reliable ingestion — but a production-ready pipeline depends on reliable delivery, observability, and recovery as well.

References and Further Reading

#AWS #AmazonKinesis #AmazonS3 #AmazonDataFirehose #Snowflake #DataEngineering #RealTimeAnalytics #StreamingData #CloudComputing
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article