For years, serverless event-driven architectures on AWS were plagued by “Lambda Glue Code”—lightweight, boilerplate Lambda functions deployed solely to pull records from an Amazon SQS queue, perform minor payload transformations, and invoke an AWS Step Functions state machine or Amazon EventBridge event bus. While simple in theory, this architecture creates severe operational friction at enterprise scale: cold-start latency spikes, runaway concurrency exhaustion, redundant CloudWatch log ingestion costs, and brittle polling error handlers. Amazon EventBridge Pipes replaces this entire layer with native, managed point-to-point connections. By combining managed source polling, in-transit JSON filtering, API destination enrichment, and direct target invocation, platform engineers achieve sub-50ms message processing with zero custom glue code. In this production engineering guide, we walk through building high-concurrency EventBridge Pipes pipelines connecting SQS and DynamoDB Streams to Step Functions and external APIs.
1. The Problem: The High Operational Cost of Lambda Glue Code
Lambda glue code refers to the practice of provisioning AWS Lambda compute functions exclusively to bridge mismatched event sources and destinations, such as transforming SQS messages before invoking Step Functions. This pattern introduces systemic cost and scaling bottlenecks under enterprise throughput.
In high-throughput architectures processing tens of millions of daily events, custom polling and connector Lambdas fail across three major dimensions:
- Concurrency Starvation: An SQS Event Source Mapping (ESM) scaling up to handle burst queues can consume hundreds of account-level unreserved Lambda concurrency slots, starving critical user-facing microservice APIs in the same AWS region.
- Double-Billing Penalty: Organizations pay for Lambda runtime execution during idle I/O while the connector function waits for downstream Step Functions or third-party webhooks to acknowledge execution requests.
- Inconsistent Dead-Letter Queue (DLQ) Semantics: Handcrafted error handling inside Lambda frequently results in poisoned messages either looping infinitely or being dropped before reaching forensic dead-letter queues.
| Feature / Dimension | Lambda Connector (Glue Code) | EventBridge Event Bus (Pub/Sub) | Amazon EventBridge Pipes (Point-to-Point) |
|---|---|---|---|
| Communication Pattern | Custom point-to-point code | Many-to-many (Broadcast / Pub-Sub) | Managed 1-to-1 point-to-point stream |
| Infrastructure Maintenance | Runtime dependencies, Node/Python updates | Event bus routing rules & schemas | Zero code; 100% managed AWS configuration |
| Payload Filtering & Enrichment | Manual application code | Basic pattern matching only | Native JSONPath filtering + API / Lambda enrich |
| Concurrency Impact | Consumes regional Lambda concurrency pool | Zero concurrency impact | Zero concurrency impact on account |
| End-to-End Latency | 50ms – 500ms (Cold starts up to 2s) | ~100ms – 300ms | Sub-40ms consistent p99 |
2. Architectural Blueprint: The 4-Stage EventBridge Pipe Pipeline
The EventBridge Pipes architecture processes messages through four strictly decoupled, ordered stages: Source, Filter, Enrichment, and Target. Each stage operates natively within the AWS managed backbone without exposing intermediate network interfaces.
- Source Stage (Ingestion & Polling): The Pipe continuously polls or subscribes to supported streaming and queue sources (Amazon SQS, DynamoDB Streams, Amazon Kinesis, Amazon MSK, or self-managed Apache Kafka). Batching windows (up to 10,000 records or 300 seconds) optimize cost and throughput.
- Filter Stage (In-Kernel Payload Pruning): Before invoking any downstream compute, Pipes evaluates JSON pattern matchers against the raw event payload. Non-matching events are discarded immediately at zero cost without triggering billing meters.
- Enrichment Stage (Synchronous Context Injection): When an event requires external data (e.g., querying customer metadata or verifying a transaction token), Pipes invokes an enrichment step—a Lambda function, API Destination, Step Functions workflow, or AWS API Gateway—and merges the response into the event body.
- Target Stage (Deterministic Delivery): The enriched, filtered payload is delivered reliably to one of over 30 supported targets, including AWS Step Functions (Standard or Express), Amazon SNS, Kinesis Firehose, or third-party webhooks via HTTP destinations.
3. Production Implementation: Provisioning EventBridge Pipes via Terraform / AWS CLI
Deploying EventBridge Pipes in enterprise production requires creating dedicated IAM roles with least-privilege KMS decryption grants and configuring strict dead-letter queue routing.
Step 1: Define IAM Execution Policy with Least Privilege
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"sqs:ReceiveMessage",
"sqs:DeleteMessage",
"sqs:GetQueueAttributes"
],
"Resource": "arn:aws:sqs:us-east-1:123456789012:orders-processing-queue"
},
{
"Effect": "Allow",
"Action": [
"states:StartExecution",
"states:StartSyncExecution"
],
"Resource": "arn:aws:states:us-east-1:123456789012:stateMachine:OrderFulfillmentWorkflow"
},
{
"Effect": "Allow",
"Action": "sqs:SendMessage",
"Resource": "arn:aws:sqs:us-east-1:123456789012:orders-dlq"
}
]
}
Step 2: Deploy the EventBridge Pipe via Terraform
The following Terraform resource provisions an automated point-to-point pipe connecting an encrypted SQS order queue directly to a Step Functions workflow, filtering only completed payment events and routing failures to a Dead Letter Queue:
resource "aws_pipes_pipe" "order_processing_pipe" {
name = "orders-to-stepfunctions-pipe"
role_arn = aws_iam_role.pipe_execution_role.arn
source = aws_sqs_queue.orders_queue.arn
target = aws_sfn_state_machine.fulfillment_workflow.arn
# 1. Source Batching Configuration
source_parameters {
sqs_queue_parameters {
batch_size = 10
maximum_batching_window_in_seconds = 5
}
}
# 2. In-Transit JSON Filtering (Discard non-paid orders at zero compute cost)
source_parameters {
filter_criteria {
filter {
pattern = jsonencode({
body = {
status = ["PAYMENT_COMPLETED"]
paymentMethod = ["CREDIT_CARD", "UPI", "NET_BANKING"]
}
})
}
}
}
# 3. Target Parameters (Invoke Step Functions Express Workflow)
target_parameters {
step_function_state_machine_parameters {
invocation_type = "FIRE_AND_FORGET"
}
input_template = jsonencode({
orderId = ""
amount = ""
customerId = ""
processedTime = ""
})
}
tags = {
Environment = "Production"
ManagedBy = "Terraform"
}
}
4. Production Gotchas: DLQs, Poison Pill Handling & Concurrency
- DynamoDB Streams Shard Blocking: When using DynamoDB Streams as a Pipe source, a single poisoned record that causes target invocation failure will block the entire shard partition indefinitely. You must configure
MaximumRetryAttempts(recommended: 3) and an activeOnFailureSQS DLQ destination to allow the stream cursor to advance. - Step Functions Express vs. Standard Execution Limits: If your target is an Express Workflow using synchronous execution (
REQUEST_RESPONSE), be aware of the 5-minute timeout window. For long-running human approval or billing workflows, always mandate Standard Workflows with asynchronousFIRE_AND_FORGETinvocation. - Input Template Quotation Escapes: When restructuring event payloads via the Pipe’s
input_template, ensure inner quotes are escaped properly. Unescaped quotes trigger silentExecutionFailederrors at the target invocation layer.
5. Diagnostic & Troubleshooting Matrix
| Error Symptom / Metric Name | Root Cause | Investigation Command | Engineering Remediation |
|---|---|---|---|
PipeExecutionFailed (TargetAccessDenied) |
IAM role lacks states:StartExecution or KMS decryption rights on target queue/key. |
aws pipes describe-pipe --name <pipe-name> |
Attach target KMS key grant and ensure execution role trust policy permits pipes.amazonaws.com. |
Pipes Dropping Filtered Messages |
Source JSON payload structure changed, causing filter pattern mismatch. | Check CloudWatch Metric: EventsFilteredOut |
Inspect raw queue messages. Ensure JSON path matches body.fieldName (SQS body is nested as a JSON string). |
Shard Iterators Expiring on DynamoDB |
Target invocation latency exceeds batch window, preventing checkpointing. | Check CloudWatch Metric: IteratorAgeMilliseconds |
Decrease batch size from 100 to 10; migrate synchronous Step Functions calls to asynchronous mode. |
Missing Dead-Letter Queue Events |
Pipe execution role lacks sqs:SendMessage permission on the designated DLQ ARN. |
Review CloudWatch Alarm: PipesTargetErrors |
Update IAM execution role policy to include explicit write access to the dead-letter queue ARN. |
6. Production Checklist & Next Steps
- Audit all existing Lambda functions whose sole purpose is reading SQS/DynamoDB and invoking Step Functions, and replace them with EventBridge Pipes.
- Enforce strict Dead-Letter Queues (DLQs) on every Pipe source to isolate malformed payloads without blocking streaming shards.
- Optimize downstream serverless compute latency by reviewing our guide on AWS Lambda Cold Start Elimination with SnapStart & Provisioned Concurrency.
- Harden multi-account network security around event processing workloads using AWS Multi-Account Transit Gateway & Network Firewall Architecture.
7. Frequently Asked Questions (FAQ)
Q1: When should I choose EventBridge Pipes over an EventBridge Event Bus?
Choose EventBridge Pipes for dedicated, high-throughput point-to-point integrations between a single source (e.g., SQS, DynamoDB Streams) and a single target (e.g., Step Functions, API) where you need built-in filtering and transformation without compute code. Choose EventBridge Event Bus when you need a decoupled, many-to-many publish-subscribe pattern where multiple independent downstream services consume the same event.
Q2: Can EventBridge Pipes handle message enrichment from external SaaS APIs?
Yes. The enrichment stage of an EventBridge Pipe natively supports API Destinations. You can configure Pipes to call external third-party HTTP endpoints (e.g., Stripe, Salesforce, or Auth0) using API keys or OAuth credentials, merging the returned data directly into the event payload before delivering it to the target.
Q3: Does EventBridge Pipes guarantee FIFO message ordering?
Yes, provided your source and target both support FIFO ordering. When consuming from an SQS FIFO queue, Kinesis Data Stream, or DynamoDB Stream, EventBridge Pipes strictly preserves message ordering per message group ID or shard partition.
Q4: How does EventBridge Pipes pricing compare to running Lambda functions?
EventBridge Pipes charges a flat rate of $0.40 per million requests, with filtering included at no additional charge. For high-volume pipelines, this is significantly cheaper than paying for continuous Lambda execution time, memory allocations, and CloudWatch log ingestion.
{
“@context”: “https://schema.org”,
“@type”: “FAQPage”,
“mainEntity”: [
{
“@type”: “Question”,
“name”: “When should I choose EventBridge Pipes over an EventBridge Event Bus?”,
“acceptedAnswer”: {
“@type”: “Answer”,
“text”: “Choose EventBridge Pipes for dedicated, high-throughput point-to-point integrations between a single source (e.g., SQS, DynamoDB Streams) and a single target (e.g., Step Functions, API) where you need built-in filtering and transformation without compute code. Choose EventBridge Event Bus when you need a decoupled, many-to-many publish-subscribe pattern where multiple independent downstream services consume the same event.”
}
},
{
“@type”: “Question”,
“name”: “Can EventBridge Pipes handle message enrichment from external SaaS APIs?”,
“acceptedAnswer”: {
“@type”: “Answer”,
“text”: “Yes. The enrichment stage of an EventBridge Pipe natively supports API Destinations. You can configure Pipes to call external third-party HTTP endpoints using API keys or OAuth credentials, merging the returned data directly into the event payload before delivering it to the target.”
}
},
{
“@type”: “Question”,
“name”: “Does EventBridge Pipes guarantee FIFO message ordering?”,
“acceptedAnswer”: {
“@type”: “Answer”,
“text”: “Yes, provided your source and target both support FIFO ordering. When consuming from an SQS FIFO queue, Kinesis Data Stream, or DynamoDB Stream, EventBridge Pipes strictly preserves message ordering per message group ID or shard partition.”
}
},
{
“@type”: “Question”,
“name”: “How does EventBridge Pipes pricing compare to running Lambda functions?”,
“acceptedAnswer”: {
“@type”: “Answer”,
“text”: “EventBridge Pipes charges a flat rate of $0.40 per million requests, with filtering included at no additional charge. For high-volume pipelines, this is significantly cheaper than paying for continuous Lambda execution time, memory allocations, and CloudWatch log ingestion.”
}
}
]
}
Recommended Hardware & Reference Architecture Literature
Tested tools and authoritative documentation to implement the architectures covered in this lab: