VAYULearn
Colour theme
Investigate a failure
VAYU Learn

AWS Data Engineering

AWS Lambda for Data Engineering: Event-Driven ETL Patterns

DataForge AWS Data Engineering Series - Blog 10 of 20

AWS Data EngineeringData Architecture & Reliability

The Lambda function had been reliably processing files for eight months - small JSON payloads, quick transformations, written to S3 in under two seconds. Then a source system started sending occasional larger files, and the function began failing intermittently with no clear pattern. Some large files processed fine. Others died mid-execution with a timeout, no partial output, no clear indication of how far processing had gotten before the function was killed.

The team’s first instinct was to increase the Lambda timeout — a reasonable guess, and it helped, briefly. Then a file arrived that took longer than even the increased timeout, then longer than Lambda’s hard 15-minute ceiling. At that point, no timeout configuration could fix it, because the actual problem wasn’t the timeout value — it was that Lambda was being used to do ETL work it was never designed for, with a runtime ceiling and memory model that fundamentally cannot scale to arbitrary data volume the way Glue or EMR can.

This is the recurring failure pattern with Lambda in data engineering: it’s an excellent trigger and a poor workhorse, and teams that use it as the workhorse eventually hit a wall that no configuration tuning can move.

Let’s go deep.


TL;DR

Lambda is a serverless compute service with a hard 15-minute execution ceiling, a memory range up to 10GB, and per-invocation cold start latency — characteristics that make it an excellent trigger and orchestration glue for event-driven pipelines, and a poor choice for the actual heavy-lifting ETL work that Glue (Blog 5) or EMR (Blog 7) are built for. Understanding exactly where Lambda’s constraints bind is what prevents building a pipeline that works in testing and fails unpredictably in production as data volume grows past what a single Lambda invocation can handle.

By the end of this article you’ll be able to:

  • Identify precisely where Lambda’s timeout, memory, and cold start constraints will break a data pipeline before you hit them in production
  • Design the correct event-driven trigger pattern connecting S3, Kinesis, and downstream compute services
  • Use Lambda Layers correctly for shared dependencies without bloating deployment packages
  • Implement error handling with Dead Letter Queues that actually surface failures instead of silently dropping them

Series context: This builds on Blog 4 (VPC networking — Lambda’s VPC attachment trade-off), Blog 8 (Kinesis — Lambda as a stream consumer), and sets up Blog 11 (Step Functions), which is what most production Lambda-triggered pipelines actually need for anything beyond the simplest single-step trigger.

Files grow from 2 seconds to 14 minutes to killed - no timeout increase saves the last one. Lambda’s ceiling is absolute. The fix isn’t more time. It’s routing large files to Glue instead of processing them directly.

Lambda’s Hard Constraints: The Numbers That Determine Everything

Every architectural decision about using Lambda in a data pipeline traces back to a small set of hard limits that no configuration can move past.

Execution timeout:     maximum 15 minutes, hard ceiling
Memory: 128MB to 10,240MB (10GB), configurable
CPU: scales proportionally with memory
allocation (more memory = more CPU,
not independently configurable)
Deployment package: 50MB zipped (direct upload),
250MB unzipped, up to 10GB via
container image
Concurrent executions: 1,000 by default per region
(soft limit, raisable)
Ephemeral storage: 512MB to 10GB (/tmp), configurable

The constraint that actually matters most for data engineering: the 15-minute timeout is not adjustable upward under any circumstances. A transformation that occasionally needs 16 minutes because of unusual data volume doesn’t get more time — it gets killed, with whatever work was in progress lost, and (depending on your error handling) potentially no clear signal that this happened beyond a generic timeout error.

Why memory and CPU are coupled: unlike EC2 or EMR where you choose CPU and memory independently, Lambda’s CPU allocation scales automatically with memory — requesting 10GB of memory gives you proportionally more CPU as well. This means a CPU-bound transformation that seems to need “more processing power” is actually solved by increasing memory allocation, not by any separate CPU configuration, which is a common point of confusion for engineers used to EC2’s independent CPU/memory sizing.


Where Lambda Genuinely Fits in a Data Pipeline

Positioning Lambda correctly requires being explicit about the boundary between “orchestration and light transformation” and “the actual ETL workload.”

Lambda is the RIGHT tool for:
Reacting to an S3 event and triggering downstream
processing (Glue job start, Step Functions execution)
Light, fast transformations on small payloads
(a single JSON record, a small batch of Kinesis
records)
Format validation and routing (inspect a file,
decide which pipeline should process it)
API-triggered data operations (a webhook receiving
a small payload that needs quick processing)
Fan-out coordination (one event triggering multiple
parallel downstream actions)
Lambda is the WRONG tool for:
Processing large files directly (multi-GB CSV/Parquet
transformation)
Any transformation whose duration scales with data
volume in a way that could exceed 15 minutes for
unusually large inputs
Stateful, multi-stage transformations that need to
maintain context across a long-running process
Anything requiring Spark, distributed processing,
or the DynamicFrame/DataFrame patterns from Blog 5

The test that clarifies which side of the line a given workload falls on: if the transformation’s runtime is bounded regardless of unexpected input size (a fixed lookup, a format check, a small aggregation over a known-small payload), Lambda is appropriate. If runtime scales with input size in a way where “unusually large input” could push past 15 minutes, Lambda is architecturally the wrong tool — not just risky, but wrong, because there is no configuration path to make it correct once that threshold is crossed.


How the S3-Triggered Pattern Actually Works: The Mechanism

This is the mechanism worth understanding precisely, because the opening scenario’s intermittent failures trace directly to using this pattern for a job whose duration wasn’t actually bounded.

File arrives in S3
|
v
S3 sends event notification (ObjectCreated)
|
v
Lambda function is invoked, receiving the S3 event
payload (bucket name, object key, size - NOT the
file's actual content)
|
v
Lambda function code:
1. Downloads the object from S3 (or streams it)
2. Processes it
3. Writes output somewhere (another S3 location,
a database, triggers another service)
|
v
Function returns, execution ends, billing stops
If step 1's file is small: fast download, fast
processing, well within timeout
If step 1's file is unexpectedly large: download
alone can consume significant time, before any
actual processing has even started - and there's
no way to know this will happen until the large
file actually arrives

The correct architectural fix for the opening scenario, not just a longer timeout: Lambda should inspect the file’s size from the S3 event metadata (available without downloading the file) and route based on size — small files processed directly in Lambda, large files triggering a Glue job or Step Functions workflow instead. This transforms Lambda from “the thing that does the work” into “the thing that decides what should do the work” — the correct architectural role.

import boto3

def lambda_handler(event, context):
s3_event = event['Records'][0]['s3']
file_size = s3_event['object']['size']
bucket = s3_event['bucket']['name']
key = s3_event['object']['key']

SIZE_THRESHOLD = 50 * 1024 * 1024 # 50MB

if file_size < SIZE_THRESHOLD:
# Small enough for Lambda to handle directly
process_small_file(bucket, key)
else:
# Too large — hand off to Glue instead
glue_client = boto3.client('glue')
glue_client.start_job_run(
JobName='large-file-processor',
Arguments={
'--source_bucket': bucket,
'--source_key': key
}
)

Lambda as a Kinesis Consumer: A Different Trigger Model

Lambda can be directly configured as a Kinesis (Blog 8) consumer, which has meaningfully different mechanics than the S3 event pattern.

Kinesis-triggered Lambda:
Lambda polls the Kinesis stream on your behalf
(you don't manage the KCL checkpointing logic
from Blog 8 directly - Lambda's event source
mapping handles it)
Batch size and batch window are configurable -
Lambda invokes once per batch, not once per record
On error: Lambda's event source mapping RETRIES
the batch automatically, and can be configured
to send failed batches to a Dead Letter Queue
after a maximum retry count
Critical behavior: if Lambda's processing of a batch
fails and retries are exhausted, by default Kinesis
processing for that shard can STALL - subsequent
records in that shard are not processed until the
failing batch is resolved, unless you configure
bisect-on-error or a destination for failed batches

Why this stall behavior matters: unlike a standalone KCL consumer where you control checkpointing explicitly (Blog 8’s discipline), Lambda’s Kinesis integration has its own retry and failure semantics that can silently block an entire shard’s downstream processing if a single malformed record causes repeated failures. Configuring BisectBatchOnFunctionError (splitting a failing batch into smaller batches to isolate the bad record) and a failure destination (SQS or SNS) prevents one bad record from stalling the entire shard indefinitely.


VPC Attachment: Revisiting Blog 4’s Trap in Lambda’s Specific Context

Blog 4 introduced the Lambda VPC attachment trap. It’s worth restating precisely here because it’s one of the most common Lambda-specific production incidents in data engineering pipelines.

Lambda WITHOUT VPC configuration:
Runs in an AWS-managed execution environment
Full internet access by default
Full access to AWS services (S3, DynamoDB, etc.)
via public AWS endpoints
NO access to resources inside your VPC (RDS in
a private subnet, an internal API)
Lambda WITH VPC configuration:
Gains access to VPC resources (RDS, internal
services)
LOSES default internet access - must have NAT
Gateway or VPC endpoints (Blog 4) configured for
the subnets the function uses, or external API
calls and non-VPC AWS service calls will fail

The specific data engineering incident this causes: a Lambda function needs to read from an RDS database (requiring VPC attachment) and also needs to call an external API for enrichment data, or write to S3. Without VPC endpoints configured for S3 (Blog 4’s free Gateway Endpoint) and a NAT Gateway for the external API, the function’s database read succeeds but its S3 write or external API call times out — a partial-failure pattern that’s confusing to diagnose because “the function ran” but produced incomplete results.


Lambda Layers: Managing Shared Dependencies Correctly

Layers let you package shared code and dependencies separately from your function code, avoiding duplication across multiple functions and keeping deployment packages manageable.

Without Layers:
Every function that needs pandas, boto3 extras,
or custom shared utility code bundles its own
copy in its deployment package
Deployment packages grow large, slow to deploy,
and duplicate the same dependency code across
every function that needs it
With Layers:
Shared dependencies packaged once as a Layer
Multiple functions reference the same Layer
Function deployment packages stay small and
focused on function-specific logic
Layer updates can be versioned independently

The specific trap Layers introduce: a Layer updated with a new library version doesn’t automatically update functions using an older Layer version — each function references a specific Layer version ARN, and forgetting to update that reference means a function silently continues running against outdated dependencies, indefinitely, unless someone explicitly checks Layer version references during a dependency upgrade.


Error Handling: Dead Letter Queues and Why Silent Failure Is the Default Without Them

Lambda’s default behavior on repeated failure is not obviously safe — understanding exactly what happens to a failed invocation is essential for any production data pipeline.

Synchronous invocation (API Gateway, direct invoke):
Caller receives the error directly
No automatic retry unless the CALLER implements it
Asynchronous invocation (S3 events, SNS, EventBridge):
Lambda automatically retries twice (3 total attempts)
After retries are exhausted: WITHOUT a configured
destination or DLQ, the event is DISCARDED -
no record, no alert, nothing
Event source mapping (Kinesis, DynamoDB Streams, SQS):
Retry behavior configurable (max retries, max
record age)
Can route failed batches to a DLQ or a Lambda
destination for handling

The critical operational fact: for S3-triggered Lambda functions (the most common data engineering pattern), a function that fails all three attempts without a configured failure destination simply loses that event — the file exists in S3, but the processing that was supposed to happen never completed and nothing surfaces that gap. This is a silent failure mode as severe as any covered elsewhere in this series, and the fix is a one-line configuration that many teams skip because Lambda “seems to be working” during initial testing when nothing fails.

# Configuring a failure destination (via infrastructure as code,
# conceptually — actual syntax depends on CloudFormation/CDK/Terraform)

lambda_function.configure_async_invoke(
FunctionName='process-s3-file',
DestinationConfig={
'OnFailure': {
'Destination': 'arn:aws:sqs:us-east-1:123456789:failed-processing-dlq'
}
}
)

Architecture Flow: Lambda’s Correct Role in a Data Pipeline

S3 file arrives
|
v
S3 Event Notification -> EventBridge
|
v
+---------------------------------------------+
| Lambda (orchestration role, not ETL) |
| |
| - Inspect file metadata (size, type) |
| - Route decision: |
| small + simple -> process directly |
| large or complex -> trigger Glue/ |
| Step Functions |
| - Configured failure destination (DLQ) |
| - VPC attached ONLY if needed, with |
| NAT/endpoints configured (Blog 4) |
+----------+-----------------------+----------+
| |
v v
Direct processing Glue Job / Step Functions
(small payloads) (actual ETL workload,
Blog 5/Blog 11)
| |
+-----------+-----------+
v
S3 Silver Layer

Failure Modes You’ll See in Production

Lambda used as the primary ETL engine, hitting the 15-minute wall. The opening scenario. A function that started small grows in scope as the pipeline matures, until data volume variability occasionally exceeds what fits in 15 minutes. Unlike Glue or EMR, there’s no configuration path forward once this ceiling is hit — the architecture itself needs to change.

Silent event loss from unconfigured failure destinations. An S3-triggered Lambda function fails processing a malformed file. After the automatic retry attempts are exhausted, the event is discarded with no DLQ configured. The file sits in S3, unprocessed, and nothing indicates this happened — the gap is discovered only when a downstream consumer notices data is missing for that period.

Kinesis-triggered Lambda stalling an entire shard. A single malformed record in a Kinesis batch causes repeated processing failures. Without BisectBatchOnFunctionError configured, the entire batch (and therefore that shard's subsequent records) stops progressing, and consumer lag for that shard climbs — the exact IteratorAgeMillisecondssymptom from Blog 8, but caused by application-level error handling gaps rather than shard capacity.

VPC attachment breaking S3 writes after adding database access. A function is VPC-attached to read from RDS. The same function’s existing S3 write, which worked fine before VPC attachment, starts timing out because VPC attachment removed default internet/AWS-service access and no S3 Gateway Endpoint (Blog 4) was configured for the new VPC context.

Lambda Layer version drift causing silent dependency inconsistency. A shared Layer is updated to patch a security vulnerability in a dependency. Several functions still reference the old Layer version ARN because nobody updated their configuration. The vulnerability remains present in those functions despite the Layer having been “fixed,” with no error or warning indicating the inconsistency.

Cold start latency causing missed SLA on latency-sensitive triggers. A Lambda function used for near-real-time processing (triggered by Kinesis or an API) has an infrequent invocation pattern, meaning most invocations pay the cold start penalty (typically hundreds of milliseconds to a few seconds, depending on runtime and package size). For a workload with a strict low-latency requirement, this cold start tax — invisible in load testing that keeps the function warm — causes intermittent SLA misses in production traffic patterns with gaps between invocations.


Trade-offs: What Lambda Optimizes For

Lambda optimizes for:

  • Zero infrastructure management — no servers, no cluster, no patching
  • True pay-per-invocation billing — no idle cost between invocations
  • Fast, event-driven reaction to triggers across the AWS ecosystem
  • Massive automatic concurrency scaling for bursty, parallelizable workloads

Lambda doesn’t optimize for:

  • Long-running or data-volume-scaling workloads — the 15-minute ceiling is absolute
  • Predictable low-latency response when invocation frequency is sparse (cold starts)
  • Complex multi-stage stateful processing within a single execution
  • Fine-grained resource control — memory/CPU coupling limits independent tuning

The honest trade-off: Lambda excels at being the reactive, coordinating layer of a data pipeline — small, fast, event-triggered actions — and is architecturally wrong for the heavy transformation work itself. Teams that respect this boundary get a highly reliable orchestration layer. Teams that push Lambda past this boundary eventually hit a hard wall that no configuration change can move.


Real-World Constraints

Deployment package size limits affect dependency-heavy functions. Data engineering functions that need pandas, numpy, or other substantial libraries can approach the 250MB unzipped limit quickly. Container image deployment (up to 10GB) is the correct escape valve for dependency-heavy functions, at the cost of slightly different deployment tooling than zip-based deployment.

Concurrent execution limits can throttle burst-triggered pipelines. A sudden burst of S3 events (a bulk upload of thousands of files) can hit the default 1,000 concurrent execution limit per region, causing throttling on the excess invocations. High-burst data pipelines need either a raised concurrency limit or an intermediate buffering layer (SQS) to smooth the burst into a rate Lambda can sustainably process.

Provisioned Concurrency addresses cold starts at a cost. For latency-sensitive Lambda triggers where cold start unpredictability is unacceptable, Provisioned Concurrency keeps a specified number of execution environments warm continuously — trading Lambda’s pure pay-per-invocation economics for consistent low latency, a cost/latency trade-off similar to Redshift Serverless vs provisioned (Blog 6).


What This Means for the Rest of the Series

Blog 11 (Step Functions): the orchestration layer that
most production Lambda-triggered
pipelines actually need once
they go beyond a single trigger-
and-forget action - Lambda often
becomes one step in a Step
Functions state machine, not the
entire pipeline
Blog 16 (Event-driven ETL pattern): assembles S3 events,
Lambda routing, and
Step Functions/Glue
into the complete
pattern this article
introduced piece by
piece

Summary: The Engineering Lesson

Lambda’s constraints aren’t limitations to work around — they’re a precise signal about what role the service is designed to play. A 15-minute ceiling that cannot be extended isn’t an oversight; it’s AWS telling you, structurally, that Lambda is not the tool for open-ended data processing.

The eight months of reliable operation before the opening scenario’s failure wasn’t luck holding out — it was the function operating within Lambda’s actual design envelope until data characteristics shifted outside it. The fix wasn’t a longer timeout. It was recognizing that Lambda’s correct role was routing and light processing, with the actual variable-duration transformation work handed off to a service built to scale with data volume.

The pattern that works: Lambda decides what should happen. Glue, EMR, or Step Functions actually make it happen. Confusing those two roles is where Lambda-based data pipelines break.


Next in Series

Blog 11 - AWS Step Functions for Data Pipeline Orchestration

This article positioned Lambda as the trigger and router, not the workhorse. Blog 11 covers what actually orchestrates the multi-step pipeline once a trigger fires — state machines with branching, retries, parallel execution, and error handling that goes well beyond what a single Lambda function’s try/except can provide.

We’ll go deep on state machine design patterns for data pipelines specifically, how Step Functions compares to Airflow for AWS-native orchestration, and the Map state pattern for processing collections of files in parallel.


Comment Below

What’s the moment you realized a Lambda function had outgrown its role in a pipeline?

Was it hitting the 15-minute timeout wall with no configuration escape hatch left? A silently dropped event that took weeks to notice because no DLQ was configured? A VPC attachment that broke an unrelated S3 write because nobody realized internet access had been removed as a side effect?

And — what did the fix actually look like: reconfiguring Lambda, or replacing it with a different service entirely for that specific job?


Tags: aws-data-engineering, aws-lambda, serverless, event-driven-architecture, kinesis, s3-events, dead-letter-queue, lambda-layers, dataforge